Skip to content

Commit 9c47bd0

Browse files
committed
Generic/DisallowYodaConditions: rename variable
This commit renames a variable to use a better name that actually matches what the variable contains. The previous name was misleading as the variable did not contain the index of the closing parenthesis.
1 parent 340a0f0 commit 9c47bd0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ public function process(File $phpcsFile, $stackPtr)
8181
// Is it a parenthesis.
8282
if ($tokens[$previousIndex]['code'] === T_CLOSE_PARENTHESIS) {
8383
// Check what exists inside the parenthesis.
84-
$closeParenthesisIndex = $phpcsFile->findPrevious(
84+
$beforeOpeningParenthesisIndex = $phpcsFile->findPrevious(
8585
Tokens::$emptyTokens,
8686
($tokens[$previousIndex]['parenthesis_opener'] - 1),
8787
null,
8888
true
8989
);
9090

91-
if ($closeParenthesisIndex === false || $tokens[$closeParenthesisIndex]['code'] !== T_ARRAY) {
92-
if ($tokens[$closeParenthesisIndex]['code'] === T_STRING) {
91+
if ($beforeOpeningParenthesisIndex === false || $tokens[$beforeOpeningParenthesisIndex]['code'] !== T_ARRAY) {
92+
if ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_STRING) {
9393
return;
9494
}
9595

@@ -111,8 +111,8 @@ public function process(File $phpcsFile, $stackPtr)
111111
if ($prev === false) {
112112
return;
113113
}
114-
} else if ($tokens[$closeParenthesisIndex]['code'] === T_ARRAY
115-
&& $this->isArrayStatic($phpcsFile, $closeParenthesisIndex) === false
114+
} else if ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_ARRAY
115+
&& $this->isArrayStatic($phpcsFile, $beforeOpeningParenthesisIndex) === false
116116
) {
117117
return;
118118
}//end if

0 commit comments

Comments
 (0)