Skip to content

Commit 931f475

Browse files
authored
Merge pull request #96 from PHPCSStandards/feature/qa-remove-unreachable-code
QA: remove unreachable code
2 parents bc001b0 + 2f77a2a commit 931f475

27 files changed

+59
-82
lines changed

phpcs.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@
142142
<type>error</type>
143143
</rule>
144144

145+
<!-- Do not allow unreachable code. -->
146+
<rule ref="Squiz.PHP.NonExecutableCode">
147+
<type>error</type>
148+
</rule>
149+
145150
<!-- The testing bootstrap file uses string concats to stop IDEs seeing the class aliases -->
146151
<rule ref="Generic.Strings.UnnecessaryStringConcat">
147152
<exclude-pattern>tests/bootstrap\.php</exclude-pattern>

src/Sniffs/AbstractScopeSniff.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ final public function process(File $phpcsFile, $stackPtr)
148148
return min($skipTokens);
149149
}
150150

151-
return;
152-
153151
}//end process()
154152

155153

src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,26 @@ public function getWarningList($testFile='')
5050
12 => 1,
5151
13 => 1,
5252
];
53-
break;
53+
5454
case 'DuplicateClassNameUnitTest.2.inc':
5555
return [
5656
2 => 1,
5757
3 => 1,
5858
4 => 1,
5959
5 => 1,
6060
];
61-
break;
61+
6262
case 'DuplicateClassNameUnitTest.5.inc':
6363
return [
6464
3 => 1,
6565
7 => 1,
6666
];
67-
break;
67+
6868
case 'DuplicateClassNameUnitTest.6.inc':
6969
return [10 => 1];
70-
break;
70+
7171
default:
7272
return [];
73-
break;
7473
}//end switch
7574

7675
}//end getWarningList()

src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ public function getErrorList($testFile='')
3030
switch ($testFile) {
3131
case 'InlineHTMLUnitTest.3.inc':
3232
return [4 => 1];
33-
break;
33+
3434
case 'InlineHTMLUnitTest.4.inc':
3535
return [1 => 1];
36-
break;
36+
3737
case 'InlineHTMLUnitTest.7.inc':
3838
return [1 => 1];
39-
break;
39+
4040
default:
4141
return [];
42-
break;
4342
}//end switch
4443

4544
}//end getErrorList()

src/Standards/Generic/Tests/Files/LineLengthUnitTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,13 @@ public function getErrorList($testFile='')
5050
45 => 1,
5151
82 => 1,
5252
];
53-
break;
53+
5454
case 'LineLengthUnitTest.2.inc':
5555
case 'LineLengthUnitTest.3.inc':
5656
return [7 => 1];
57-
break;
57+
5858
default:
5959
return [];
60-
break;
6160
}//end switch
6261

6362
}//end getErrorList()
@@ -89,20 +88,19 @@ public function getWarningList($testFile='')
8988
75 => 1,
9089
84 => 1,
9190
];
92-
break;
91+
9392
case 'LineLengthUnitTest.2.inc':
9493
case 'LineLengthUnitTest.3.inc':
9594
return [6 => 1];
96-
break;
95+
9796
case 'LineLengthUnitTest.4.inc':
9897
return [
9998
10 => 1,
10099
14 => 1,
101100
];
102-
break;
101+
103102
default:
104103
return [];
105-
break;
106104
}//end switch
107105

108106
}//end getWarningList()

src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc
122122
499 => 1,
123123
500 => 1,
124124
];
125-
break;
125+
126126
case 'MultipleStatementAlignmentUnitTest.js':
127127
return [
128128
11 => 1,
@@ -154,10 +154,9 @@ public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc
154154
114 => 1,
155155
117 => 1,
156156
];
157-
break;
157+
158158
default:
159159
return [];
160-
break;
161160
}//end switch
162161

163162
}//end getWarningList()

src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ public function getErrorList($testFile='')
3030
switch ($testFile) {
3131
case 'CharacterBeforePHPOpeningTagUnitTest.1.inc':
3232
return [2 => 1];
33-
break;
33+
3434
default:
3535
return [];
36-
break;
3736
}//end switch
3837

3938
}//end getErrorList()

src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public function getErrorList($testFile='')
3030
switch ($testFile) {
3131
case 'ClosingPHPTagUnitTest.1.inc':
3232
return [9 => 1];
33+
3334
case 'ClosingPHPTagUnitTest.2.inc':
3435
return [5 => 1];
35-
break;
36+
3637
default:
3738
return [];
38-
break;
3939
}
4040

4141
}//end getErrorList()

src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc')
5252
95 => 1,
5353
100 => 2,
5454
];
55-
break;
55+
5656
case 'LowerCaseConstantUnitTest.js':
5757
return [
5858
2 => 1,
@@ -64,10 +64,9 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc')
6464
13 => 1,
6565
14 => 1,
6666
];
67-
break;
67+
6868
default:
6969
return [];
70-
break;
7170
}//end switch
7271

7372
}//end getErrorList()

src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function getErrorList($testFile='')
3030
switch ($testFile) {
3131
case 'RequireStrictTypesUnitTest.1.inc':
3232
return [];
33-
break;
3433
}
3534

3635
return [1 => 1];

0 commit comments

Comments
 (0)