-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In PHPStan 1.12.0 with bleeding edge generated annotations @method for tables are reported #1002
Comments
In the meantime you can just use https://github.com/dereuromark/cakephp-ide-helper to automatically generate all the necessary annotations so static analysis is happy. |
Both Bake and IdeHelper are currently not adding @Harfusha Do u want to make a PR here? |
And how should i implement it? Should i add or the specific entity? I would rather add specific entity. |
As specific as possible, sure. |
Do all major IDEs understand/support this new "bleeding edge generated annotations"? I wonder what issues this could bring for IDE usage (and developers). For Psalm/PHPStan this update is sure useful. The red marked errors are |
But this annotation was already in use.
Edit: |
Jep. Only input apparently. |
Can you please test if we can use Entity[] instead of itterable? |
Yes, so
seems fine here on bake side, and rest could probably be on IdeHelper side. |
Ok i will update it this way :) |
Oh but itterable<> and Entity[] is not same, i dont know if this change is wise. I will revert it back to itterable |
The main point is that any EntityInterface collection is accepted right? So But sure, either way works. |
But when entities are fetched only using ->all() i will show errors, and you cannot set it to be array of entites, because that will mean that you cannot use any functions of the iterable like ->isEmpty( |
It more and more sounds like we shouldnt touch the Bake templates and rather make it all an opt-in topic for IdeHelper. |
Yeah, only change i made in the end was array => mixed[] :D |
Description
dereuromark/cakephp-ide-helper#353
\src\Model\Table\AccountsTable.php:55:Class App\Model\Table\AccountsTable has PHPDoc tag @method for method newEntity() parameter #1 $data with no value type specified in iterable type array.
\src\Model\Table\AccountsTable.php:55:Class App\Model\Table\AccountsTable has PHPDoc tag @method for method newEntity() parameter #2 $options with no value type specified in iterable type array.
This problem is with array type in params and with iterable type in params
@method \App\Model\Entity\Account newEntity(array $data, array $options = [])
This should be updated to this
@method \App\Model\Entity\Account newEntity(array<mixed> $data, array<mixed> $options = [])
@method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Account>|false saveMany(iterable $entities, $options = [])
This should be updated to this
@method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Account>|false saveMany(iterable<mixed> $entities, $options = [])
Or better to
@method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Account>|false saveMany(iterable<\App\Model\Entity\Account> $entities, $options = [])
PHPStan issue: phpstan/phpstan#11593
Edit more issues found:
@method \App\Model\Entity\Service[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
C:\Workplace\many\many\src\Controller\ServicesController.php:60:PHPDoc tag @method for method App\Controller\ServicesController::paginate() return type contains generic interface Cake\Datasource\ResultSetInterface but does not specify its types: T
(Used annotations are changed by dereuromark/cakephp-ide-helper, but the issue is same)
Bake Version
PHP Version
8.3
The text was updated successfully, but these errors were encountered: