Skip to content

bug: Fix non-parenthesized callable return type parse#6961

Merged
kubawerlos merged 4 commits intoPHP-CS-Fixer:masterfrom
mvorisek:fix_return_type_parse
May 18, 2023
Merged

bug: Fix non-parenthesized callable return type parse#6961
kubawerlos merged 4 commits intoPHP-CS-Fixer:masterfrom
mvorisek:fix_return_type_parse

Conversation

@mvorisek
Copy link
Copy Markdown
Contributor

\Closure: int|float must be parsed as (\Closure: int) | float

Parenthesized type can be parsed as of #6796.

TypeExpressionTest::testGetTypes is improved to test if the type is really split/parsed as expected.

Also fix empty string parse ('', "").

@mvorisek mvorisek changed the title Fix non-parenthesized callable return type parse bug: Fix non-parenthesized callable return type parse May 15, 2023
Copy link
Copy Markdown
Member

@Wirone Wirone left a comment

Choose a reason for hiding this comment

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

\Closure: int|float must be parsed as (\Closure: int) | float

Can you share reference to the source stating this? The other day I saw discussion about it and people weren't completely sure how it should be treated, I have doubts too. It's important, because it's either bug fix or BC break 😅.

@mvorisek
Copy link
Copy Markdown
Contributor Author

mvorisek commented May 18, 2023

\Closure: int|float must be parsed as (\Closure: int) | float

see phpstan/phpstan#9268, this is how it must be dumped and how it is parsed already by static analysers

given this fact, a callable return type union requires parenthesis

proof: https://phpstan.org/r/afa05b01-9dc1-4f74-b8b0-45d259a944e8

@kubawerlos kubawerlos merged commit 733dd38 into PHP-CS-Fixer:master May 18, 2023
@kubawerlos
Copy link
Copy Markdown
Member

Thank you @mvorisek and @Wirone 👍🏼

@mvorisek mvorisek deleted the fix_return_type_parse branch May 18, 2023 22:22
@AJenbo
Copy link
Copy Markdown
Contributor

AJenbo commented May 22, 2023

thanks

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants