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 ConstantArrayType callables with union values #1529

Merged
merged 1 commit into from Jul 20, 2022

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Jul 20, 2022

Closes phpstan/phpstan#2343

I basically just transformed findTypeAndMethodName(): ?ConstantArrayTypeAndMethod to findTypeAndMethodNames(): ConstantArrayTypeAndMethod[].

Comment on lines +389 to 390
/** @deprecated Use findTypeAndMethodNames() instead */
public function findTypeAndMethodName(): ?ConstantArrayTypeAndMethod
Copy link
Contributor Author

@herndlm herndlm Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the best approach here is. I wanted to play it safe and don't touch it at all. But findTypeAndMethodNames is basically a super set of this one. What I want to say - this most likely could be replaced by smth like

/** @deprecated Use findTypeAndMethodNames() instead  */
public function findTypeAndMethodName(): ?ConstantArrayTypeAndMethod
{
    $typeAndMethodNames = $this->findTypeAndMethodNames();
    return count($typeAndMethodNames) === 1 ? $typeAndMethodNames[0] : null;
}

Fyi inside of phpstan it is unused already.

@herndlm herndlm marked this pull request as ready for review July 20, 2022 10:46
@ondrejmirtes
Copy link
Member

This is really nice, thank you! :)

@ondrejmirtes ondrejmirtes merged commit c460b56 into phpstan:1.8.x Jul 20, 2022
@herndlm herndlm deleted the fix-2343 branch July 20, 2022 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants