1.2.1377. Useless Brackets¶
Standalone brackets have no use. Brackets are used to delimit a block of code, and are used by control statements. They may also be used to protect variables in strings.
Standalone brackets may be a left over of an old instruction, or a misunderstanding of the alternative syntax.
<?php
// The following brackets are useless : they are a leftover from an older instruction
// if (DEBUG)
{
$a = 1;
}
// Here, the extra brackets are useless
for($a = 2; $a < 5; $a++) : {
$b++;
} endfor;
?>
1.2.1377.1. Suggestions¶
Remove the brackets
Restore the flow-control operation that was there and removed
Move the block into a method or function, and call it
1.2.1377.2. Specs¶
Short name |
Structures/UselessBrackets |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Features |
block, curly-bracket |
Examples |
|
Available in |