-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix phpstan errors #3824
Fix phpstan errors #3824
Conversation
@morozov I don't know how to best handle the last 3 errors:
dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php Line 1319 in e0a92b0
Any advice? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 tests forcibly use a wrong type to ensure that an exception is thrown, but of course this makes phpstan unhappy
Drop them. This is what PHPStan is for :-)
Here
array_keys()
is called on an array that only has string keys, but phpstan doesn't understand this, and assumes that the result is an array containingint|string
It should have been fixed as per phpstan/phpstan#1847 but it seems it isn't. It looks like out of the two related suppressions only one is needed (the other is already removed in master, please rebase). Please leave the remaining one for now, file a PHPStan issue that would reproduce our case in their sandbox (same as it was done in phpstan/phpstan#1847) and update the reference to point to the newly created issue in our PHPStan configuration.
Done!
Done.
Strangely, it doesn't happen in their sandbox: https://phpstan.org/r/eea2b886-3942-425d-8ecd-b50489599ff5 I've double checked, the fix should be included in the phpstan version we're using, too, so I don't understand. Any idea? |
The difference may be in the config. Please put together the simplest possible example that gets flagged with our version and config and then see if it depends on the config. Then report whatever reproducible issue. IIRC, not all issues are reproducible in the sandbox (e.g. phpstan/phpstan#2510). |
Finally reproduced it, and reported as phpstan/phpstan#2857. I forgot to include the exception class in the sandbox, obviously. But for some reason phpstan didn't complain about the missing class at all. |
@morozov All good now! 👍 |
@BenMorel, looks good! Please squash. |
To get rid of the remaining PHPStan issue, we may replace the associative array representing a join in the Query Builder with an object similar to |
Just for my information, what's wrong with the "Squash & Merge" button on GitHub?
I'd love to replace associative arrays with objects. I may try to play with this next. |
|
@morozov Thanks. Squashed! |
Thanks, @BenMorel! |
Summary
Fixes more phpstan errors, as suggested in #3801.