diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 7d27a8aa12..240b46e55f 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -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. diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc index 983b3f3734..b4f481d4ee 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc @@ -283,6 +283,13 @@ echo $j; echo $j; ?> + + + +