1.2.830. No Plus One¶
Incrementing a variable should be done with the ++ or – operators. Any other way, may be avoided.
This is a micro optimisation.
<?php
// Best way to increment
++$x; --$y;
// Second best way to increment, if the current value is needed :
echo $x++, $y--;
// Good but slow
$x += 1;
$x -= -1;
$y += -1;
$y -= 1;
// even slower
$x = $x + 1;
$y = $y - 1;
?>
1.2.830.1. Specs¶
Short name |
Structures/PlusEgalOne |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |