diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index 879ebb5bcd..933b0e381a 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -201,16 +201,16 @@ if (true) catch(Exception $e) { } -switch ($num) { - case 0: - if (1 > $num) - return bar( - baz( - "foobarbaz" - ) - ); - break; -} +for ($i = 0; $i <= 4; $i++) + if ($i % 2) + return bar( + baz( + "foobarbaz" + ) + ); + + + do { $i++; diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index 6c25496ed5..8c2574044f 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -230,18 +230,19 @@ if (true) { } } -switch ($num) { - case 0: - if (1 > $num) { - return bar( - baz( - "foobarbaz" - ) - ); - } - break; +for ($i = 0; $i <= 4; $i++) { + if ($i % 2) { + return bar( + baz( + "foobarbaz" + ) + ); + } } + + + do { $i++; } diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index 19c78e0f96..22eeb075cc 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -70,7 +70,8 @@ public function getErrorList($testFile='') 191 => 1, 195 => 1, 198 => 1, - 206 => 1, + 204 => 1, + 205 => 1, 222 => 1, 232 => 1, 235 => 1, diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc index 6c71d80db0..8df21a6c35 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc @@ -117,3 +117,16 @@ switch ($type) { } break; } + +// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/1590 +switch ($num) { + /* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */ + case 0: + if (1 > $num) + return bar( + baz( + "foobarbaz" + ) + ); + break; +} diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php index 8b651c6d43..a4f3c3f089 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php @@ -208,6 +208,13 @@ public static function dataNotEnumCases() 'scope_closer' => T_BREAK, ], ], + 'switch case, nested inline if' => [ + 'testMarker' => '/* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_BREAK, + ], + ], ]; }//end dataNotEnumCases()