Skip to content

[CodeQuality] Add CoalesceToTernaryRector - #7960

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

TomasVotruba merged 5 commits into
mainfrom
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

samsonasik commented Apr 5, 2026

Copy link
Copy Markdown
Member Author

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
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants