1.2.1390. Useless Coalesce¶
The ?: operator needs the condition to be potentially empty. This means that the type should have the possibility to be null, false, 0, or any of the empty values.
<?php
function foo(A $a, bool $b) {
$a ?: 'a';
$b ?: 'a';
}
?>
1.2.1390.1. Suggestions¶
Remove the operator.
Extend the type to include values that may be empty.
1.2.1390.2. Specs¶
Short name |
Structures/UselessCoalesce |
Rulesets |
|
Exakat since |
2.6.6 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |