-
Notifications
You must be signed in to change notification settings - Fork 478
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
Validate array function callback #555
Validate array function callback #555
Conversation
af19c52
to
061b13e
Compare
827de8a
to
989ea3f
Compare
Hi, thank you for this. I pushed some commits with improvements. The reason why I postponed doing this is because most functions seem pretty complicated to be described with just generics. |
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.
To be worth finishing this and merging this, I'd like more examples of these functions that would benefit from this. Like usort()
etc.
de33a9d
to
5b3fe9b
Compare
True, looking into it the more commonly used functions like array_map, need more than just generics. Prehaps some kind of |
I've added the stubs for usort uasort and uksort. And removed array_map, as it is incorrect.
I'm not sure how i should go about this |
The way it works is:
How to implement it here:
|
The (extra) failures on PHP 8 are due to param names |
The tests need to account for this with |
I can't figure out why for that one job the tests would fail. |
I'll look into it. Thanks! |
Thanks for the merge and the help @ondrejmirtes! |
Fixes phpstan/phpstan#3883
This adds type checks for callables on array_map, array_reduce and array_walk.
Currently
array_filter
is not checked, as the params for the callable depend on the mode param, so that may need an extension of some kind.This alos fixes new issues found by these checks