This is a code snippet from a php function used in a software package I installed:
$i = 0;
$extra_small_header_field_values = array();
while ($i < $i_len && $i !== false) {
/* get argument */
$read = trim(substr($read,$i));
$i_len = strlen($read);
$i = strpos($read,' ');
$arg = substr($read,0,$i);
++$i;
The line containing ++$i; results in a warning Increment on type bool has no effect,.
My question is why is $i considered a boolean here? I realize that in PHP a boolean is a special class of integer but how does $i get to be considered a boolean given its evident prior treatment as an integer in the preceding code? How is this issue most correctly addressed?
This should work for you.
The problem is because of how
$iis used in thewhileloop the condition checks if$iis not equal tofalseand if it is, the loop stops. But here's the catch if the loop terminates because$ibecomesfalsethe next time around it tries to increment a boolean value and that's a not good, triggering the warning. To fix this, you need to make sure you're not trying to increment a boolean variable.