Skip to content

Improve parenthesization for union types#1433

Merged
ondrejmirtes merged 1 commit intophpstan:1.7.xfrom
rvanvelzen:union-parens
Jun 17, 2022
Merged

Improve parenthesization for union types#1433
ondrejmirtes merged 1 commit intophpstan:1.7.xfrom
rvanvelzen:union-parens

Conversation

@rvanvelzen
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was doubting to do this regardless of level, but for precise/cache the template scope and variance is appended which already makes it unambiguous.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FYI I usually keep AnalyserIntegrationTest for things that crashed PHPStan/caused infinite loop. It's better to put the test in a specific rule test case. (or a specific rule test case + NodeScopeResolverTest for type inference verification).

But I'm gonna merge it like this so that the fix isn't belated :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll keep it in mind :)

Copy link
Copy Markdown
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Oh actually, it looks lit's adding parentheses in more cases where it isn't necessary, and breaking people's baselines: https://github.com/phpstan/phpstan-src/runs/6933410671?check_suite_focus=true, https://github.com/phpstan/phpstan-src/runs/6933409913?check_suite_focus=true, https://github.com/phpstan/phpstan-src/runs/6933409824?check_suite_focus=true

I'd say that if the template type is last, the parenthesis isn't necessary...

@ondrejmirtes
Copy link
Copy Markdown
Member

Even though there are failures, I'm happy with the results now!

@ondrejmirtes ondrejmirtes merged commit 99ddeaf into phpstan:1.7.x Jun 17, 2022
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@rvanvelzen rvanvelzen deleted the union-parens branch June 17, 2022 12:05
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.

Generator expects key type K of int|string, K of int|string given.

2 participants