1.2.1053. Return True False¶
These conditional expressions return true/false, depending on the condition. This may be simplified by dropping the control structure altogether. This may be simplified with : This may be applied to assignations and ternary operators too.
<?php
if (version_compare($a, $b) >= 0) {
return true;
} else {
return false;
}
?>
1.2.1053.1. Connex PHP features¶
1.2.1053.1.1. Suggestions¶
Return directly the comparison, without using the if/then structure
Cast the value to (boolean) and use it instead of the ternary
1.2.1053.1.2. Specs¶
Short name |
Structures/ReturnTrueFalse |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Examples |
|
Available in |