Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Callable prototypes #430

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

Closed
dktapps wants to merge 10 commits into phpstan:master from pmmp:callable-prototypes
Closed

Callable prototypes #430

dktapps wants to merge 10 commits into phpstan:master from pmmp:callable-prototypes

Conversation

@dktapps
Copy link
Contributor

@dktapps dktapps commented Jan 24, 2021

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).

szepeviktor reacted with rocket emoji
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)) {
Copy link
Contributor Author

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.

Copy link
Member

@ondrejmirtes ondrejmirtes Jan 24, 2021

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.

Copy link
Member

I've already added a few commits locally, I'm taking over the PR, thanks.

Copy link
Member

In master. Thank you.

Copy link
Member

@dktapps Please submit a documentation change that explains this setting somewhere here: https://phpstan.org/config-reference#stricter-analysis Thanks.

Copy link
Contributor Author

dktapps commented Jan 24, 2021

Awesome, thanks! Will attend to the docs as soon as I get home.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /