diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index 1b02430859..617bfb9684 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -297,3 +297,22 @@ foreach ($array as $sniffShouldBailEarly) /* some comment */; do ; while ($sniffShouldBailEarly > 5); + +do echo $i++; while ($i < 5); + +// phpcs:set Generic.ControlStructures.InlineControlStructure error false +if ($something) echo 'hello'; +// phpcs:set Generic.ControlStructures.InlineControlStructure error true + +for ($i = 0; $i < 5; $i++) + if ($i === 3) { + echo 'three'; + } elseif ($i === 4) { + echo 'four'; + } elseif ($i === 5) { + echo 'five'; + } + +if ($noSpaceAfterClosingParenthesis)echo 'hello'; ?> + +scenario == 'simple' ) $widget->renderPager() ?> diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index ad03ad626f..649c023faa 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -336,3 +336,26 @@ foreach ($array as $sniffShouldBailEarly) /* some comment */; do ; while ($sniffShouldBailEarly > 5); + +do { echo $i++; +} while ($i < 5); + +// phpcs:set Generic.ControlStructures.InlineControlStructure error false +if ($something) { echo 'hello'; +} +// phpcs:set Generic.ControlStructures.InlineControlStructure error true + +for ($i = 0; $i < 5; $i++) { + if ($i === 3) { + echo 'three'; + } elseif ($i === 4) { + echo 'four'; + } elseif ($i === 5) { + echo 'five'; + } +} + +if ($noSpaceAfterClosingParenthesis) { echo 'hello'; +} ?> + +scenario == 'simple' ) { $widget->renderPager(); } ?> diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.10.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.10.inc new file mode 100644 index 0000000000..6de22da665 --- /dev/null +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.10.inc @@ -0,0 +1,9 @@ + 1, 278 => 1, 289 => 1, + 301 => 1, + 307 => 1, + 316 => 1, + 318 => 1, + ]; + + case 'InlineControlStructureUnitTest.10.inc': + return [ + 6 => 1, + ]; + + case 'InlineControlStructureUnitTest.11.inc': + return [ + 7 => 1, ]; default: @@ -97,11 +111,21 @@ public function getErrorList($testFile='') * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return []; + switch ($testFile) { + case 'InlineControlStructureUnitTest.1.inc': + return [ + 304 => 1, + ]; + + default: + return []; + } }//end getWarningList()