This will always be printed as the if is closed by the PHP close tag. This will always be printed as the elseif is closed by the PHP close tag. This will always be printed as the else is closed by the PHP close tag. This will always be printed as the for is closed by the PHP close tag. $c); // Surprisingly enough not a parse error. /* testForEachWithoutBodyDueToCloseTag */ foreach($a as $b => $c) ?> This will always be printed as the foreach is closed by the PHP close tag. $v) { // phpcs:ignore Stnd.Cat.Sniff -- for reasons. } /* testForEachWithCode */ foreach ($a as $k => $v) { echo "Key: $k; Current value of \$a: $v.\n"; } /* testWhileWithoutBody */ while (++$i <= 10) /*comment*/ ; /* testWhileWithoutBodyDueToCloseTag */ while (++$i <= 10) ?> This will always be printed as the while is closed by the PHP close tag. something'; break; } /* testDeclareWithoutBody */ declare(ticks=1); /* testDeclareWithoutBodyDueToCloseTag */ declare(ticks=1) ?> $v): // Comment. endforeach; /* testAlternativeForeachWithCode */ foreach ($a as $k => $v): echo "Key: $k; Current value of \$a: $v.\n"; endforeach; /* testAlternativeWhileEmptyBody */ while (++$i <= 10): // phpcs:disable Stnd.Cat.Sniff -- for reasons. endwhile; /* testAlternativeWhileWithCode */ while (++$i <= 10): echo $i; endwhile; /* testAlternativeSwitchEmptyBody */ switch ($foo) : endswitch; /* testAlternativeSwitchWithCode */ switch ($foo) : case 1: echo '
something
'; endswitch; /* testAlternativeDeclareEmptyBody */ declare (ticks = 1): // comment enddeclare; /* testAlternativeDeclareWithCode */ declare (ticks = 1): echo 'ticking'; enddeclare; /* * Control structures without braces. * Without a body, these are a parse error straight away. */ /* testInlineIfWithCode */ if (true) function_call($a); /* testInlineElseIfWithCode */ elseif (false) function_call($a); /* testInlineElseWithCode */ else function_call($a); /* testInlineForWithCode */ for ($i = 1; $i <= 10; $i++) echo $i; /* testInlineForEachWithCode */ foreach ($a as $k => $v) echo "Key: $k; Current value of \$a: $v.\n"; /* testInlineWhileWithCode */ while (++$i <= 10) echo $i; /* testInlineDoWhileWithCode */ do echo $i; while (++$i <= 10); /* * PHP 8.0 match expressions. */ /* testMatchEmptyBody */ // Intentional fatal error, "unhandled match case", but not the concern of this method. $match = match($a) {}; /* testMatchEmptyBodyWithComment */ // Intentional fatal error, "unhandled match case", but not the concern of this method. $match = match($a) { // Deliberately empty. }; /* testMatchWithCode */ $match = match ($a) { 0 => 'Foo', 1 => 'Bar', 2 => 'Baz', }; // Live coding. // Intentional parse error. This test has to be the last in the file. if ($a) { // Code. /* testElseLiveCoding */ } else { // Code.