You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usort accepts a passed-by-reference array of array<array-key, T> as first argument, but will always transform that argument into array<int, T>. This is also noted in the php docs:
Note: This function assigns new keys to the elements in array. It will remove any existing keys that may have been assigned, rather than just reordering the keys.
So when giving usort an array of array<string, T> the passed array becomes array<int, T>. PHPStan however does not pick this up. I looked at updating the functionMap.php file, but I did not see how this can be documented in the current format. If I missed something I'd be happy to provide a pull request with an update to it!
Bug report
usort
accepts a passed-by-reference array ofarray<array-key, T>
as first argument, but will always transform that argument intoarray<int, T>
. This is also noted in the php docs:So when giving
usort
an array ofarray<string, T>
the passed array becomesarray<int, T>
. PHPStan however does not pick this up. I looked at updating thefunctionMap.php
file, but I did not see how this can be documented in the current format. If I missed something I'd be happy to provide a pull request with an update to it!Code snippet that reproduces the problem
The snippet that reproduces can be found here:
https://phpstan.org/r/cd33a591-5f93-4df3-b878-49af85ef487e
I've also confirmed the behavior as described in the php docs with the same code in this 3v4l.org test.
Expected output
I would've expected PHPStan not to return an error. Both Psalm and Phan do not return any error about this.
The text was updated successfully, but these errors were encountered: