Improve parenthesization for union types#1433
Conversation
src/Type/UnionType.php
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
I'll keep it in mind :)
ondrejmirtes
left a comment
There was a problem hiding this comment.
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...
|
Even though there are failures, I'm happy with the results now! |
|
Thank you! |
Fixes phpstan/phpstan#7484