1.2.1395. Useless Short Ternary¶
The short ternary operates on empty or null values. When the type of the condition is not false, boolean or null, the operator is useless.
<?php
function foo() : A { return new A; }
// This is useless
$b = foo() ? 1;
?>
1.2.1395.1. Suggestions¶
Remove the ternary operator
Refactor the types to allow for empty values
1.2.1395.2. Specs¶
Short name |
Structures/UselessShortTernary |
Rulesets |
|
Exakat since |
2.6.5 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
short-ternary |
Available in |