diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index 41efffa4df..bc4a916d20 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr) // Ignore the ELSE in ELSE IF. We'll process the IF part later. if ($tokens[$stackPtr]['code'] === T_ELSE) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($tokens[$next]['code'] === T_IF) { return; } diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index fb4a7380fb..739ba40a6d 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -272,3 +272,7 @@ function testFinally() } finally { } } + +if ($something) { + echo 'hello'; +} else /* comment */ if ($somethingElse) echo 'hi'; diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index d80a32652a..9a89b0e387 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -307,3 +307,8 @@ function testFinally() } } } + +if ($something) { + echo 'hello'; +} else /* comment */ if ($somethingElse) { echo 'hi'; +} diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js index 4d3b1e8aa2..ca6dae13a0 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js @@ -29,3 +29,7 @@ if ($("#myid").rotationDegrees()=='90') if ($("#myid").rotationDegrees()=='90') $foo = {'transform': 'rotate(90deg)'}; + +if (something) { + alert('hello'); +} else /* comment */ if (somethingElse) alert('hi'); diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed index 8f0c413e75..d410cfb122 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed @@ -37,3 +37,8 @@ if ($("#myid").rotationDegrees()=='90') { if ($("#myid").rotationDegrees()=='90') { $foo = {'transform': 'rotate(90deg)'}; } + +if (something) { + alert('hello'); +} else /* comment */ if (somethingElse) { alert('hi'); +} diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index 44f1d74716..5d42d1122a 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -78,6 +78,7 @@ public function getErrorList($testFile='') 242 => 1, 260 => 1, 269 => 1, + 278 => 1, ]; case 'InlineControlStructureUnitTest.js': @@ -90,6 +91,7 @@ public function getErrorList($testFile='') 21 => 1, 27 => 1, 30 => 1, + 35 => 1, ]; default: