Commit 2ed3aa8
authored
Don't require parentheses for short-ternaries (#7604)
Chaining of short-ternaries (`?:` also called elvis operator) is stable
and behaves reasonably
This is described in the PHP Manual right below the warning about using
nested ternary expressions.
The example code is taken from the PHP Manual.
https://www.php.net/manual/en/language.operators.comparison.php#:~:text=Chaining%20of%20short%2Dternaries%20(%3F%3A)%2C%20however%2C%20is%20stable%20and%20behaves%20reasonably1 parent 8376d26 commit 2ed3aa8
2 files changed
Lines changed: 14 additions & 0 deletions
File tree
- rules-tests/Php74/Rector/Ternary/ParenthesizeNestedTernaryRector/Fixture
- rules/Php74/Rector/Ternary
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| |||
0 commit comments