1.2.1096. Several Instructions On The Same Line¶
Usually, instructions do not share their line : one instruction, one line.
This is good for readability, and help at understanding the code. This is especially important when fast-reading the code to find some special situation, where such double-meaning line way have an impact.
<?php
switch ($x) {
// Is it a fallthrough or not ?
case 1:
doSomething(); break;
// Easily spotted break.
case 1:
doSomethingElse();
break;
default :
doDefault();
break;
}
?>
See also Object Calisthenics, rule # 5.
1.2.1096.1. Suggestions¶
Add new lines, so that one expression is on one line
1.2.1096.2. Specs¶
Short name |
Structures/OneLineTwoInstructions |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Examples |
|
Available in |