Loosen the requirements for the $function parameter of the register_shutdown_function function#240
Loosen the requirements for the $function parameter of the register_shutdown_function function#240ondrejmirtes merged 1 commit intophpstan:masterfrom ste93cry:fix/issue-2998-register-shutdown-function-false-positive
Conversation
…hutdown_function function
|
Hi, I don't think that the void return typehint is the problem. The problem is that |
I agree, but I was not sure about the syntax to require a
Maybe I didn't understand the issue you're seeing, but all the arguments after the first one are passed to the callback, so in the case of the example snippet what's happening is that I'm calling the |
|
Shouldn't we think about this more generally? It should probably be okay to pass a closure that returns a value somewhere a callable with |
In a strongly typed language it would be forbidden because function signature would not match, so I don't think we should encourage users that doing this in PHP is fine. The issue I'm trying to solve is that the first argument of |
|
Alright :) |
|
Do you think it would be possible to improve what I did to check that the arguments passed to the |
|
@ste93cry That would only be possible with a custom rule. But you can do this instead: register_shutdown_function(function (): void use ($foo, $bar) {
}); |
Fixes phpstan/phpstan#2998, by loosening the requirements of the
$functionargument of theregister_shutdown_functionfunction