diff --git a/VariableAnalysis/Lib/Helpers.php b/VariableAnalysis/Lib/Helpers.php index 268732de..947d3813 100644 --- a/VariableAnalysis/Lib/Helpers.php +++ b/VariableAnalysis/Lib/Helpers.php @@ -23,7 +23,7 @@ public static function getIntOrNull($value) { */ public static function findContainingOpeningSquareBracket(File $phpcsFile, $stackPtr) { $previousStatementPtr = self::getPreviousStatementPtr($phpcsFile, $stackPtr); - return self::getIntOrNull($phpcsFile->findPrevious(T_OPEN_SHORT_ARRAY, $stackPtr - 1, $previousStatementPtr)); + return self::getIntOrNull($phpcsFile->findPrevious([T_OPEN_SHORT_ARRAY], $stackPtr - 1, $previousStatementPtr)); } /** @@ -37,7 +37,7 @@ public static function findContainingClosingSquareBracket(File $phpcsFile, $stac if (! $endOfStatementPtr) { return null; } - return self::getIntOrNull($phpcsFile->findNext(T_CLOSE_SHORT_ARRAY, $stackPtr + 1, $endOfStatementPtr)); + return self::getIntOrNull($phpcsFile->findNext([T_CLOSE_SHORT_ARRAY], $stackPtr + 1, $endOfStatementPtr)); } /** @@ -196,7 +196,7 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr) { $argPtrs = []; $lastPtr = $openPtr; $lastArgComma = $openPtr; - $nextPtr = $phpcsFile->findNext(T_COMMA, $lastPtr + 1, $closePtr); + $nextPtr = $phpcsFile->findNext([T_COMMA], $lastPtr + 1, $closePtr); while (is_int($nextPtr)) { if (Helpers::findContainingOpeningBracket($phpcsFile, $nextPtr) == $openPtr) { // Comma is at our level of brackets, it's an argument delimiter. @@ -204,7 +204,7 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr) { $lastArgComma = $nextPtr; } $lastPtr = $nextPtr; - $nextPtr = $phpcsFile->findNext(T_COMMA, $lastPtr + 1, $closePtr); + $nextPtr = $phpcsFile->findNext([T_COMMA], $lastPtr + 1, $closePtr); } array_push($argPtrs, range($lastArgComma + 1, $closePtr - 1)); @@ -226,8 +226,8 @@ public static function findWhereAssignExecuted(File $phpcsFile, $stackPtr) { // However, if we're within a bracketed expression, we take place at the // closing bracket, if that's first. // eg: echo (($var = 12) && ($var == 12)); - $semicolonPtr = $phpcsFile->findNext(T_SEMICOLON, $stackPtr + 1, null, false, null, true); - $commaPtr = $phpcsFile->findNext(T_COMMA, $stackPtr + 1, null, false, null, true); + $semicolonPtr = $phpcsFile->findNext([T_SEMICOLON], $stackPtr + 1, null, false, null, true); + $commaPtr = $phpcsFile->findNext([T_COMMA], $stackPtr + 1, null, false, null, true); $closePtr = false; $openPtr = Helpers::findContainingOpeningBracket($phpcsFile, $stackPtr); if ($openPtr !== null) { diff --git a/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php b/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php index d0a26e5e..e53a5b0c 100644 --- a/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php +++ b/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php @@ -187,7 +187,7 @@ protected function isGetDefinedVars(File $phpcsFile, $stackPtr) { return false; } // Make sure this is a function call - $parenPointer = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, $stackPtr + 2); + $parenPointer = $phpcsFile->findNext([T_OPEN_PARENTHESIS], $stackPtr, $stackPtr + 2); if (! $parenPointer) { return false; } @@ -500,7 +500,7 @@ protected function checkForFunctionPrototype(File $phpcsFile, $stackPtr, $varNam return true; } // $functionPtr is at the use, we need the function keyword for start of scope. - $functionPtr = $phpcsFile->findPrevious(T_CLOSURE, $functionPtr - 1, $currScope + 1, false, null, true); + $functionPtr = $phpcsFile->findPrevious([T_CLOSURE], $functionPtr - 1, $currScope + 1, false, null, true); if (! is_bool($functionPtr)) { $this->markVariableDeclaration($varName, 'bound', null, $stackPtr, $functionPtr); $this->markVariableAssignment($varName, $stackPtr, $functionPtr); @@ -684,7 +684,7 @@ protected function checkForStaticMember(File $phpcsFile, $stackPtr, $varName, $c } // "When calling static methods, the function call is stronger than the // static property operator" so look for a function call. - $parenPointer = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, $stackPtr + 2); + $parenPointer = $phpcsFile->findNext([T_OPEN_PARENTHESIS], $stackPtr, $stackPtr + 2); if ($parenPointer) { return false; }