Skip to content

Commit 544f9ab

Browse files
rodrigoprimojrfnl
authored andcommitted
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 2fb2d7d commit 544f9ab

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
@@ -80,15 +80,15 @@ public function process(File $phpcsFile, $stackPtr)
8080

8181
// Is it a parenthesis.
8282
if ($tokens[$previousIndex]['code'] === T_CLOSE_PARENTHESIS) {
83-
$closeParenthesisIndex = $phpcsFile->findPrevious(
83+
$beforeOpeningParenthesisIndex = $phpcsFile->findPrevious(
8484
Tokens::$emptyTokens,
8585
($tokens[$previousIndex]['parenthesis_opener'] - 1),
8686
null,
8787
true
8888
);
8989

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

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

0 commit comments

Comments
 (0)