Skip to content

Commit 5be26b4

Browse files
authored
Always use array for first arg of findPrevious/Next (#131)
Not sure why phpstan is complaining about this now, but it seems to hink that T_OPEN_SHORT_ARRAY, etc, are strings rather than integers. Doing this makes it quiet down. This should have no real effect.
1 parent 984a0ae commit 5be26b4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

VariableAnalysis/Lib/Helpers.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static function getIntOrNull($value) {
2323
*/
2424
public static function findContainingOpeningSquareBracket(File $phpcsFile, $stackPtr) {
2525
$previousStatementPtr = self::getPreviousStatementPtr($phpcsFile, $stackPtr);
26-
return self::getIntOrNull($phpcsFile->findPrevious(T_OPEN_SHORT_ARRAY, $stackPtr - 1, $previousStatementPtr));
26+
return self::getIntOrNull($phpcsFile->findPrevious([T_OPEN_SHORT_ARRAY], $stackPtr - 1, $previousStatementPtr));
2727
}
2828

2929
/**
@@ -37,7 +37,7 @@ public static function findContainingClosingSquareBracket(File $phpcsFile, $stac
3737
if (! $endOfStatementPtr) {
3838
return null;
3939
}
40-
return self::getIntOrNull($phpcsFile->findNext(T_CLOSE_SHORT_ARRAY, $stackPtr + 1, $endOfStatementPtr));
40+
return self::getIntOrNull($phpcsFile->findNext([T_CLOSE_SHORT_ARRAY], $stackPtr + 1, $endOfStatementPtr));
4141
}
4242

4343
/**
@@ -196,15 +196,15 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr) {
196196
$argPtrs = [];
197197
$lastPtr = $openPtr;
198198
$lastArgComma = $openPtr;
199-
$nextPtr = $phpcsFile->findNext(T_COMMA, $lastPtr + 1, $closePtr);
199+
$nextPtr = $phpcsFile->findNext([T_COMMA], $lastPtr + 1, $closePtr);
200200
while (is_int($nextPtr)) {
201201
if (Helpers::findContainingOpeningBracket($phpcsFile, $nextPtr) == $openPtr) {
202202
// Comma is at our level of brackets, it's an argument delimiter.
203203
array_push($argPtrs, range($lastArgComma + 1, $nextPtr - 1));
204204
$lastArgComma = $nextPtr;
205205
}
206206
$lastPtr = $nextPtr;
207-
$nextPtr = $phpcsFile->findNext(T_COMMA, $lastPtr + 1, $closePtr);
207+
$nextPtr = $phpcsFile->findNext([T_COMMA], $lastPtr + 1, $closePtr);
208208
}
209209
array_push($argPtrs, range($lastArgComma + 1, $closePtr - 1));
210210

@@ -226,8 +226,8 @@ public static function findWhereAssignExecuted(File $phpcsFile, $stackPtr) {
226226
// However, if we're within a bracketed expression, we take place at the
227227
// closing bracket, if that's first.
228228
// eg: echo (($var = 12) && ($var == 12));
229-
$semicolonPtr = $phpcsFile->findNext(T_SEMICOLON, $stackPtr + 1, null, false, null, true);
230-
$commaPtr = $phpcsFile->findNext(T_COMMA, $stackPtr + 1, null, false, null, true);
229+
$semicolonPtr = $phpcsFile->findNext([T_SEMICOLON], $stackPtr + 1, null, false, null, true);
230+
$commaPtr = $phpcsFile->findNext([T_COMMA], $stackPtr + 1, null, false, null, true);
231231
$closePtr = false;
232232
$openPtr = Helpers::findContainingOpeningBracket($phpcsFile, $stackPtr);
233233
if ($openPtr !== null) {

VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ protected function isGetDefinedVars(File $phpcsFile, $stackPtr) {
187187
return false;
188188
}
189189
// Make sure this is a function call
190-
$parenPointer = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, $stackPtr + 2);
190+
$parenPointer = $phpcsFile->findNext([T_OPEN_PARENTHESIS], $stackPtr, $stackPtr + 2);
191191
if (! $parenPointer) {
192192
return false;
193193
}
@@ -500,7 +500,7 @@ protected function checkForFunctionPrototype(File $phpcsFile, $stackPtr, $varNam
500500
return true;
501501
}
502502
// $functionPtr is at the use, we need the function keyword for start of scope.
503-
$functionPtr = $phpcsFile->findPrevious(T_CLOSURE, $functionPtr - 1, $currScope + 1, false, null, true);
503+
$functionPtr = $phpcsFile->findPrevious([T_CLOSURE], $functionPtr - 1, $currScope + 1, false, null, true);
504504
if (! is_bool($functionPtr)) {
505505
$this->markVariableDeclaration($varName, 'bound', null, $stackPtr, $functionPtr);
506506
$this->markVariableAssignment($varName, $stackPtr, $functionPtr);
@@ -684,7 +684,7 @@ protected function checkForStaticMember(File $phpcsFile, $stackPtr, $varName, $c
684684
}
685685
// "When calling static methods, the function call is stronger than the
686686
// static property operator" so look for a function call.
687-
$parenPointer = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, $stackPtr + 2);
687+
$parenPointer = $phpcsFile->findNext([T_OPEN_PARENTHESIS], $stackPtr, $stackPtr + 2);
688688
if ($parenPointer) {
689689
return false;
690690
}

0 commit comments

Comments
 (0)