|
10 | 10 |
|
11 | 11 | class Helpers { |
12 | 12 | /** |
13 | | - * return int[] |
| 13 | + * @return array<int|string> |
14 | 14 | */ |
15 | 15 | public static function getPossibleEndOfFileTokens() { |
16 | 16 | return array_merge( |
@@ -259,7 +259,7 @@ public static function findFunctionCall(File $phpcsFile, $stackPtr) { |
259 | 259 | * @param File $phpcsFile |
260 | 260 | * @param int $stackPtr |
261 | 261 | * |
262 | | - * @return array[] |
| 262 | + * @return array<int, array<int>> |
263 | 263 | */ |
264 | 264 | public static function findFunctionCallArguments(File $phpcsFile, $stackPtr) { |
265 | 265 | $tokens = $phpcsFile->getTokens(); |
@@ -291,13 +291,21 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr) { |
291 | 291 | while (is_int($nextPtr)) { |
292 | 292 | if (Helpers::findContainingOpeningBracket($phpcsFile, $nextPtr) == $openPtr) { |
293 | 293 | // Comma is at our level of brackets, it's an argument delimiter. |
294 | | - array_push($argPtrs, range($lastArgComma + 1, $nextPtr - 1)); |
| 294 | + $range = range($lastArgComma + 1, $nextPtr - 1); |
| 295 | + $range = array_filter($range, function($element) { |
| 296 | + return is_int($element); |
| 297 | + }); |
| 298 | + array_push($argPtrs, $range); |
295 | 299 | $lastArgComma = $nextPtr; |
296 | 300 | } |
297 | 301 | $lastPtr = $nextPtr; |
298 | 302 | $nextPtr = $phpcsFile->findNext([T_COMMA], $lastPtr + 1, $closePtr); |
299 | 303 | } |
300 | | - array_push($argPtrs, range($lastArgComma + 1, $closePtr - 1)); |
| 304 | + $range = range($lastArgComma + 1, $closePtr - 1); |
| 305 | + $range = array_filter($range, function($element) { |
| 306 | + return is_int($element); |
| 307 | + }); |
| 308 | + array_push($argPtrs, $range); |
301 | 309 |
|
302 | 310 | return $argPtrs; |
303 | 311 | } |
@@ -477,7 +485,7 @@ public static function isTokenInsideArrowFunctionDefinition(File $phpcsFile, $st |
477 | 485 | $tokens = $phpcsFile->getTokens(); |
478 | 486 | $token = $tokens[$stackPtr]; |
479 | 487 | $openParenIndices = isset($token['nested_parenthesis']) ? $token['nested_parenthesis'] : []; |
480 | | - if ($openParenIndices) { |
| 488 | + if (empty($openParenIndices)) { |
481 | 489 | return false; |
482 | 490 | } |
483 | 491 | $openParenPtr = $openParenIndices[0]; |
@@ -561,7 +569,7 @@ public static function isArrowFunction(File $phpcsFile, $stackPtr) { |
561 | 569 | * @param File $phpcsFile |
562 | 570 | * @param int $stackPtr |
563 | 571 | * |
564 | | - * @return ?array |
| 572 | + * @return ?array<string, int> |
565 | 573 | */ |
566 | 574 | public static function getArrowFunctionOpenClose(File $phpcsFile, $stackPtr) { |
567 | 575 | $tokens = $phpcsFile->getTokens(); |
@@ -613,7 +621,7 @@ public static function getArrowFunctionOpenClose(File $phpcsFile, $stackPtr) { |
613 | 621 | * @param File $phpcsFile |
614 | 622 | * @param int $listOpenerIndex |
615 | 623 | * |
616 | | - * @return ?array |
| 624 | + * @return ?array<int> |
617 | 625 | */ |
618 | 626 | public static function getListAssignments(File $phpcsFile, $listOpenerIndex) { |
619 | 627 | $tokens = $phpcsFile->getTokens(); |
|
0 commit comments