Bug report
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!
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.
Bug report
usortaccepts 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
usortan array ofarray<string, T>the passed array becomesarray<int, T>. PHPStan however does not pick this up. I looked at updating thefunctionMap.phpfile, 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.