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

Support string callables via array_filter #6417

Closed
herndlm opened this issue Jan 19, 2022 · 3 comments · Fixed by phpstan/phpstan-src#938
Closed

Support string callables via array_filter #6417

herndlm opened this issue Jan 19, 2022 · 3 comments · Fixed by phpstan/phpstan-src#938

Comments

@herndlm
Copy link
Contributor

herndlm commented Jan 19, 2022

Feature request

array_filter is already understanding complex closures or arrow functions via ArrayFilterFunctionReturnTypeReturnTypeExtension but interestingly it can't deal with more simple string-callables like is_string. Would be great if it could understand that as well.

It looks like TypeSpecifyingFunctionsDynamicReturnTypeExtension is dealing with the narrowing-down of those simple type specifying functions and therefore maybe somehow related.

See https://phpstan.org/r/33b86b4b-41ae-4953-b062-80d11a74ffb2

Did PHPStan help you today? Did it make you happy in any way?

Yes for sure. And I was impressed that it can narrow down arrays to lists via $a === array_values($a) :)

@staabm
Copy link
Contributor

staabm commented Jan 22, 2022

Maybe we could just rewite the ast of the string-arg example to the closure one seen on the 2nd example?

@herndlm
Copy link
Contributor Author

herndlm commented Jan 22, 2022

Maybe we could just rewite the ast of the string-arg example to the closure one seen on the 2nd example?

Had the same idea already as well. Maybe it is the simplest implementation :) I'll check it out later

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

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 Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants