Skip to content

Commit a331259

Browse files
committed
Squiz/EmbeddedPhp: add some extra defensive coding
`$firstContentAfterBlock` should not be able to be `false` at this point as it is already checked and handled at the top of the function, but better to be safe than sorry.
1 parent 901e654 commit a331259

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag
284284
$phpcsFile->fixer->addNewlineBefore($closingTag);
285285
$phpcsFile->fixer->endChangeset();
286286
}//end if
287-
} else if ($tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']) {
287+
} else if ($firstContentAfterBlock !== false
288+
&& $tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']
289+
) {
288290
$error = 'Closing PHP tag must be on a line by itself';
289291
$fix = $phpcsFile->addFixableError($error, $closingTag, 'ContentAfterEnd');
290292
if ($fix === true) {

0 commit comments

Comments
 (0)