1.2.423. Empty With Expression¶
empty() doesn’t accept expressions until PHP 5.5. Until then, it is necessary to store the result of the expression in a variable and then, test it with empty().
<?php
// PHP 5.5+ empty() usage
if (empty(strtolower($b . $c))) {
doSomethingWithoutA();
}
// Compatible empty() usage
$a = strtolower($b . $c);
if (empty($a)) {
doSomethingWithoutA();
}
?>
See also empty.
1.2.423.1. Connex PHP features¶
1.2.423.1.1. Suggestions¶
Use the compatible syntax, and store the result in a local variable before testing it with empty
1.2.423.1.2. Specs¶
Short name |
Structures/EmptyWithExpression |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
With PHP 5.5 and more recent |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Changed Behavior |
PHP 5.5 |
Precision |
Very high |
Examples |
|
Available in |