-
Notifications
You must be signed in to change notification settings - Fork 664
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
Allow non-string keys #3221
Allow non-string keys #3221
Conversation
@muglug I would like to write a test, but I don't understand how they are organized. Can you recommend an existing file, or should I create a new one? |
8223d30
to
333a51b
Compare
@@ -249,11 +249,12 @@ function uksort(array &$arr, callable $callback): bool | |||
} | |||
|
|||
/** | |||
* @psalm-template K of array-key |
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.
🤔 maybe I should remove the of array-key
part?
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.
You may do that, however it really shouldn't do any harm. After all, array keys could only be array-key
. Come to think of it, it may even be useful to catch situations when Psalm wrongly infers key types, like here: https://psalm.dev/r/5c1dae6bd1
Answering my own question: https://github.com/vimeo/psalm/blob/master/tests/ArrayFunctionCallTest.php looks like a good candidate |
333a51b
to
082c1fa
Compare
The same with a test, please review :) |
Although it would be stupid to provide an array with exclusively non-string keys, it's possible to have an array with a bit of both. See for instance https://github.com/doctrine/dbal/blob/155d028be084ef69110d09938c57c351a2126e5d/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php#L263-L276
082c1fa
to
8c1a183
Compare
Thanks! |
Although it would be stupid to provide an array with exclusively
non-string keys, it's possible to have array with a bit of both.
See for instance
https://github.com/doctrine/dbal/blob/155d028be084ef69110d09938c57c351a2126e5d/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php#L263-L276