diff --git a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php index 6d39207b36..3dc7795b37 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php @@ -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; } @@ -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