Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag
}

// Check for a blank line at the bottom.
if ((isset($tokens[$lastContent]['scope_closer']) === false
|| $tokens[$lastContent]['scope_closer'] !== $lastContent)
$lastNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($closingTag - 1), ($stackPtr + 1), true);
if ((isset($tokens[$lastNonEmpty]['scope_closer']) === false
|| $tokens[$lastNonEmpty]['scope_closer'] !== $lastNonEmpty)
&& $tokens[$lastContent]['line'] < ($tokens[$closingTag]['line'] - 1)
) {
// Find a token on the blank line to throw the error on.
Expand Down
7 changes: 7 additions & 0 deletions src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ echo $j;
echo $j;
?>

<?php
enum BlankLineBeforeCloseShouldBeIgnoredWhenLastBeforeIsCloseCurlyForScope
{
}//trailing comment

?>

<?php
// This test case file MUST always end with an unclosed long open PHP tag (with this comment) to prevent
// the tests running into the "last PHP closing tag excepted" condition breaking tests.
Expand Down
7 changes: 7 additions & 0 deletions src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ echo $j;
echo $j;
?>

<?php
enum BlankLineBeforeCloseShouldBeIgnoredWhenLastBeforeIsCloseCurlyForScope
{
}//trailing comment

?>

<?php
// This test case file MUST always end with an unclosed long open PHP tag (with this comment) to prevent
// the tests running into the "last PHP closing tag excepted" condition breaking tests.
Expand Down