Use the Elvis operator ?:
where possible.
Risky when relying on functions called on both sides of the ?
operator.
--- Original
+++ New
<?php
-$foo = $foo ? $foo : 1;
+$foo = $foo ? : 1;
--- Original
+++ New
-<?php $foo = $bar[a()] ? $bar[a()] : 1; # "risky" sample, "a()" only gets called once after fixing
+<?php $foo = $bar[a()] ? : 1; # "risky" sample, "a()" only gets called once after fixing
The rule is part of the following rule sets: