Skip to content

[CodeQuality] Add CoalesceToTernaryRector#7960

Merged
TomasVotruba merged 5 commits intomainfrom
code-quality-coalesce-to-ternary
Apr 6, 2026
Merged

[CodeQuality] Add CoalesceToTernaryRector#7960
TomasVotruba merged 5 commits intomainfrom
code-quality-coalesce-to-ternary

Conversation

@samsonasik
Copy link
Copy Markdown
Member

@samsonasik samsonasik requested a review from TomasVotruba April 5, 2026 16:29
@samsonasik
Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

@samsonasik
Copy link
Copy Markdown
Member Author

samsonasik commented Apr 5, 2026

For note, it change behaviour, see

which should be on purpose ...

@TomasVotruba
Copy link
Copy Markdown
Member

Seems this would change behavior to different result.
What is the original use case in the real world this resolves?

@samsonasik
Copy link
Copy Markdown
Member Author

This cause phpstan issue in the first place, which can be a wrong code to begin with

https://phpstan.org/r/42726037-b5d2-4b25-b627-f9b91e22021c

We had it in our project, which non nullable in the left, that's why I place it in the last order of code quality.

I can unregister it if needed because in case of eg string, and empty string passed, it goes left value over right one, while transformed result cause got right.

@TomasVotruba
Copy link
Copy Markdown
Member

I can unregister it if needed because in case of eg string, and empty string passed, it goes left value over right one, while transformed result cause got right.

Let's do that and test it first. If it shows no edge-cases in next 2-3 months, we can add it to the set after.

@samsonasik
Copy link
Copy Markdown
Member Author

sure, I've unregister it 👍 a7478ec

@TomasVotruba TomasVotruba merged commit 3e751ec into main Apr 6, 2026
60 checks passed
@TomasVotruba
Copy link
Copy Markdown
Member

Thank you 👍

@TomasVotruba TomasVotruba deleted the code-quality-coalesce-to-ternary branch April 6, 2026 17:56
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.

Rule to convert ?? to ?: on non-nullable type

2 participants