Closed
Description
The below example is taken from ADOdb/ADOdb
's replicate include:
foreach ($sql as $s)
if (!$this->execute) echo "<pre>",$s.";\n</pre>";
else {
$ok = $this->connDest->Execute($s);
if (!$ok)
if ($this->neverAbort) $ret = false;
else return false;
}
In this example, what causes the issue is the lack of braces. When phpcbf
encounters the for
, and then the else, it is putting braces around the block it believes to be the for
-statement and then around the if
but then moves the else
to become part of the for which will cause a fatal error in PHP. The result of running phpcbf --standard=PSR2
is:
foreach ($sql as $s) {
if (!$this->execute) {
echo "<pre>",$s.";\n</pre>";
}
} else {
$ok = $this->connDest->Execute($s);
if (!$ok) {
if ($this->neverAbort) {
$ret = false;
}
} else {
return false;
}
}