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
PHPStan thinks array_column returns an array which has arrays as keys #6682
Comments
/cc @jlherren (the author of phpstan/phpstan-src#970 and phpstan/phpstan-src#948) - can you please look into this to see who's wrong here? :) Thanks! |
Oof, yes arrays as keys is weird. Most likely there should be a |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Using phpstan 1.4.6 on PHP 7.4
Hi, 21 days ago, so right after the release of v1.4.4 (22 days ago) the daily build on ekino/phpstan-banned-code for PHP 7.4 broke. Could it be possible that this is due to this pull request? phpstan/phpstan-src#948
Code snippet that reproduces the problem
Example: https://phpstan.org/r/ac9d1992-138e-4925-82cd-1de3e3f93676
Expected output
phpstan analyze
complains:which in a simplified version means that phpstan thinks that
array_column
will return anarray<array|int|string|null, array>
, in other words an array that can have arrays as its keys.So thanks to your great bug report template which asks all the right questions I just realised why I got this message.
Now my followup question: Is this logic correct? It seems to me PHP really puts an integer as the key if you try with an array.
In this example here I intentionally put "foo" instead of "type" into array_column to provoke the problem:
http://sandbox.onlinephpfunctions.com/code/381d0182b85cc698b02b18b82cd9dae0da3f7a00
Did PHPStan help you today? Did it make you happy in any way?
PHPStan always makes me happy, it keeps my code clean and kills lots of bugs in their larva stage! <3
The text was updated successfully, but these errors were encountered: