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
Callable prototypes #430
Callable prototypes #430
Conversation
TypeTraverser::map($type, static function (Type $type, callable $traverse) use (&$result): Type { | ||
if ( | ||
($type instanceof CallableType && $type->isCommonCallable()) || | ||
($type instanceof ObjectType && $type->getClassName() === \Closure::class)) { |
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.
This is the only thing I'm not happy with. I think there should be a better, more generalized way to do this, but if there is one it's not apparent to me.
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.
This is probably fine... There's Type::isCallable()
and Type::getCallableParametersAcceptors()
but there's no way to extract whether it's general callable or already specified callable from that.
So as long as this place is synchronized with TypeNodeResolver::resolveCallableTypeNode()
, we're fine.
I've already added a few commits locally, I'm taking over the PR, thanks. |
In master. Thank you. |
@dktapps Please submit a documentation change that explains this setting somewhere here: https://phpstan.org/config-reference#stricter-analysis Thanks. |
Awesome, thanks! Will attend to the docs as soon as I get home. |
This is a working implementation, although a bit rough around the edges.
A new toggle
checkMissingCallablePrototype
is added, disabled by default (as per @ondrejmirtes request).