1.2.90. Buried Assignation¶
Those assignations are buried in the code, and placed in unexpected situations.
They are difficult to spot, and may be confusing. It is advised to place them in a more visible place.
<?php
// $b may be assigned before processing $a
$a = $c && ($b = 2);
// Display property p immeiately, but also, keeps the object for later
echo ($o = new x)->p;
// legit syntax, but the double assignation is not obvious.
for($i = 2, $j = 3; $j < 10; $j++) {
}
?>
1.2.90.1. Suggestions¶
Extract the assignation and set it on its own line, prior to the current expression.
Check if the local variable is necessary
1.2.90.2. Specs¶
Short name |
Structures/BuriedAssignation |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Examples |
|
Available in |