Why PHPStan isn't strict about callback return type? #10454
-
Just noticed I can pass a callback with any return type to array_filter, and PHPStan silently accepts it: But array_filter's second argument is correctly typed as a callable with a Yeah, there's a warning in PHP docs that says
But I believe this kind of silent type casting is bug prone. Especially with strict typing enabled, when some programmers might believe PHP will throw an error on example like that. Shouldn't PHPStan yield some warning about callable return type mismatch? Or there's some meaningful intention behind ignoring it that I don't understand? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Fixed: phpstan/phpstan-src@59ae706 |
Beta Was this translation helpful? Give feedback.
Fixed: phpstan/phpstan-src@59ae706