Skip to content

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
Development

Successfully merging this pull request may close these issues.

Improve constant array as callable with unions of constant strings
2 participants