1.2.1112. Short Ternary¶
Short ternaries are the ternary operator, where the middle operand was left out.
Written that way, the operator checks if the first operand is empty() : in that case, the second operand is used; Otherwise, the first operand is used.
<?php
// $b is now 2
$b = $a ?: 2;
// $c is now 2 also
$c = $b ?: 4;
?>
See also Ternary Operator.
1.2.1112.1. Connex PHP features¶
1.2.1112.1.1. Specs¶
Short name |
Php/ShortTernary |
Rulesets |
|
Exakat since |
2.5.2 |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |