Skip to content

Commit 58b328b

Browse files
committed
Generic InlineControlStructureSniff now correctly fixes ELSEIF statements
1 parent bef1fc8 commit 58b328b

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function register()
5858
return array(
5959
T_IF,
6060
T_ELSE,
61+
T_ELSEIF,
6162
T_FOREACH,
6263
T_WHILE,
6364
T_DO,

CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,7 @@ foreach($stuff as $num)
138138
if (true) {
139139
echo "true2\n";
140140
}
141+
142+
if ($foo) echo 'foo';
143+
elseif ($bar) echo 'bar';
144+
else echo 'baz';

CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ foreach($stuff as $num) {
139139
if (true) {
140140
echo "true2\n";
141141
}
142+
143+
if ($foo) { echo 'foo'; }
144+
elseif ($bar) { echo 'bar'; }
145+
else { echo 'baz'; }

CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public function getErrorList($testFile='InlineControlStructureUnitTest.inc')
6565
120 => 1,
6666
128 => 1,
6767
134 => 1,
68+
142 => 1,
69+
143 => 1,
70+
144 => 1,
6871
);
6972
break;
7073
case 'InlineControlStructureUnitTest.js':

package.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
4646
- Added more guard code for foreach declarations with syntax errors
4747
-- Thanks to Johan de Ruijter for the patch
4848
- Added more guard code for class declarations with syntax errors
49-
- Squiz ArrayDeclaration now has guard code for arrays with syntax errors
49+
- Squiz ArrayDeclarationSniff now has guard code for arrays with syntax errors
50+
- Generic InlineControlStructureSniff now correctly fixes ELSEIF statements
5051
- Fixed bug #601 : Expected type hint int[]; found array in Squiz FunctionCommentSniff
5152
-- Thanks to Scato Eggen for the patch
5253
- Fixed bug #625 : Consider working around T_HASHBANG in HHVM 3.5.x and 3.6.x

0 commit comments

Comments
 (0)