Skip to content

Commit

Permalink
Generic/DisallowYodaConditions: rename variable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rodrigoprimo authored and jrfnl committed May 13, 2024
1 parent fd9d74e commit 48a1a43
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ public function process(File $phpcsFile, $stackPtr)

// Is it a parenthesis.
if ($tokens[$previousIndex]['code'] === T_CLOSE_PARENTHESIS) {
$closeParenthesisIndex = $phpcsFile->findPrevious(
$beforeOpeningParenthesisIndex = $phpcsFile->findPrevious(
Tokens::$emptyTokens,
($tokens[$previousIndex]['parenthesis_opener'] - 1),
null,
true
);

if ($closeParenthesisIndex === false || $tokens[$closeParenthesisIndex]['code'] !== T_ARRAY) {
if ($tokens[$closeParenthesisIndex]['code'] === T_STRING) {
if ($beforeOpeningParenthesisIndex === false || $tokens[$beforeOpeningParenthesisIndex]['code'] !== T_ARRAY) {
if ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_STRING) {
return;
}

Expand All @@ -110,8 +110,8 @@ public function process(File $phpcsFile, $stackPtr)
if ($prev === false) {
return;
}
} else if ($tokens[$closeParenthesisIndex]['code'] === T_ARRAY
&& $this->isArrayStatic($phpcsFile, $closeParenthesisIndex) === false
} else if ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_ARRAY
&& $this->isArrayStatic($phpcsFile, $beforeOpeningParenthesisIndex) === false
) {
return;
}//end if
Expand Down

0 comments on commit 48a1a43

Please sign in to comment.