-
Notifications
You must be signed in to change notification settings - Fork 488
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
Add generic typings to array_uintersect #3806
base: 2.1.x
Are you sure you want to change the base?
Conversation
This PR is a partial fix for phpstan/phpstan#7707, if this PR is the correct way to do this I can add support for the other functions mentioned as well |
a51ad7a
to
ba154ee
Compare
This pull request has been marked as ready for review. |
array $one, | ||
array $two, | ||
callable $three | ||
): int {} |
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.
It'd be better to update the array_udiff and array_uintersect to actually use two different @template
for each array (T + U).
I see, I missed this when looking through issues. However there's a slight difference in that the arrays can be different per @ondrejmirtes' suggestion. The same issue with that PR is still present here; the definitions of these functions are wrong, but merging this would get us closer to PHPStan fully understanding these functions |
@axlon You're right. Feel free to take whatever you want from the original PR, if you decide to expand this one to cover all similar functions. Alternatively, I'm also around to update my PR if ondrejmirtes prefers that. |
array $one, | ||
array $two, | ||
callable $three | ||
): int {} |
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.
Both array_udiff
and array_uintersect
return an array, not int: https://3v4l.org/R0WNi
I'll try to take a look at this soon |
This PR adds generic typings to
array_uintersect
, I copied the annotations fromarray_udiff