Skip to content
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

Standard PHP function are not checked if array and callback type matches - support generics in functionMap #4920

Closed
olsavmic opened this issue Apr 28, 2021 · 2 comments

Comments

@olsavmic
Copy link

Feature request

Hi,
I was surprised to find out that PHPStan does not support checking if types match in case of native function like array_map/array_filter and similar.

https://phpstan.org/r/d7ff2afa-6d0a-436f-9011-dee78f6d994e#

I suppose that's due to the fact that the functionMap.php does not support generics or at least the generic types are not specified.

I would really appreciate if it could be done at least for some of the most used methods as it gives a false sense of security now with runtime error :)

Do you think it is possible to add support for something like this in the future?

Thanks a lot!

@olsavmic olsavmic changed the title Standard array function do not check if array and callback type matches - support generics in functionMap Standard PHP function are not checked if array and callback type matches - support generics in functionMap Apr 28, 2021
@ondrejmirtes
Copy link
Member

Duplicate of: #1954

Support for stub files overriding internal functions could be added, but array_map and array_filter have a lot of special handling in the core already, and I worry that generics would clash with that so there needs to be special care applied during the implementation.

One example of such special handling is: https://phpstan.org/r/a9f6a271-8f4d-4dee-b1ce-8a82cabdc51e

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants