Skip to content

Commit 6875b9e

Browse files
committed
Squiz/EmbeddedPhp: rename two confusingly named variables
1 parent 61e20af commit 6875b9e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag
7878
$firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
7979

8080
if ($closingTag !== false) {
81-
$nextContent = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true);
82-
if ($nextContent === false) {
81+
$firstContentAfterBlock = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true);
82+
if ($firstContentAfterBlock === false) {
8383
// Final closing tag. It will be handled elsewhere.
8484
return;
8585
}
@@ -171,9 +171,9 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag
171171
}//end if
172172
}//end if
173173

174-
$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
175-
if ($tokens[$lastContent]['line'] === $tokens[$stackPtr]['line']
176-
&& trim($tokens[$lastContent]['content']) !== ''
174+
$lastContentBeforeBlock = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
175+
if ($tokens[$lastContentBeforeBlock]['line'] === $tokens[$stackPtr]['line']
176+
&& trim($tokens[$lastContentBeforeBlock]['content']) !== ''
177177
) {
178178
$error = 'Opening PHP tag must be on a line by itself';
179179
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentBeforeOpen');
@@ -227,8 +227,8 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag
227227
return;
228228
}
229229

230-
$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closingTag - 1), ($stackPtr + 1), true);
231-
$nextContent = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), null, true);
230+
$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closingTag - 1), ($stackPtr + 1), true);
231+
$firstContentAfterBlock = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), null, true);
232232

233233
if ($tokens[$lastContent]['line'] === $tokens[$closingTag]['line']) {
234234
$error = 'Closing PHP tag must be on a line by itself';
@@ -240,7 +240,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag
240240
$phpcsFile->fixer->addNewlineBefore($closingTag);
241241
$phpcsFile->fixer->endChangeset();
242242
}
243-
} else if ($tokens[$nextContent]['line'] === $tokens[$closingTag]['line']) {
243+
} else if ($tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']) {
244244
$error = 'Closing PHP tag must be on a line by itself';
245245
$fix = $phpcsFile->addFixableError($error, $closingTag, 'ContentAfterEnd');
246246
if ($fix === true) {

0 commit comments

Comments
 (0)