Skip to content

Commit

Permalink
Squiz/EmbeddedPhp: add some extra defensive coding
Browse files Browse the repository at this point in the history
`$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.
  • Loading branch information
jrfnl committed Jan 8, 2024
1 parent 7818a66 commit 9973c3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag
$phpcsFile->fixer->addNewlineBefore($closingTag);
$phpcsFile->fixer->endChangeset();
}//end if
} else if ($tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']) {
} else if ($firstContentAfterBlock !== false
&& $tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']
) {
$error = 'Closing PHP tag must be on a line by itself';
$fix = $phpcsFile->addFixableError($error, $closingTag, 'ContentAfterEnd');
if ($fix === true) {
Expand Down

0 comments on commit 9973c3b

Please sign in to comment.