@@ -93,7 +93,7 @@ public static function findContainingOpeningBracket(File $phpcsFile, $stackPtr)
9393 $ tokens = $ phpcsFile ->getTokens ();
9494 if (isset ($ tokens [$ stackPtr ]['nested_parenthesis ' ])) {
9595 /**
96- * @var array <int|string|null >
96+ * @var list <int|string>
9797 */
9898 $ openPtrs = array_keys ($ tokens [$ stackPtr ]['nested_parenthesis ' ]);
9999 return (int )end ($ openPtrs );
@@ -364,9 +364,6 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr)
364364 if (self ::findContainingOpeningBracket ($ phpcsFile , $ nextPtr ) === $ openPtr ) {
365365 // Comma is at our level of brackets, it's an argument delimiter.
366366 $ range = range ($ lastArgComma + 1 , $ nextPtr - 1 );
367- $ range = array_filter ($ range , function ($ element ) {
368- return is_int ($ element );
369- });
370367 array_push ($ argPtrs , $ range );
371368 $ lastArgComma = $ nextPtr ;
372369 }
@@ -384,93 +381,85 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr)
384381
385382 /**
386383 * Compatibility handler for phpcs 3.x/4.x
387- * @return array
384+ * @return array<int|string, int|string>
388385 */
389386 public static function getOoScopeTokens ()
390387 {
391388 if (defined ('Tokens::OO_SCOPE_TOKENS ' )) {
392389 return Tokens::OO_SCOPE_TOKENS ;
393390 }
394- if (isset (Tokens::$ ooScopeTokens )) {
395- return Tokens::$ ooScopeTokens ;
396- }
397- return [];
391+ return Tokens::$ ooScopeTokens ;
398392 }
399393
400394 /**
401395 * Compatibility handler for phpcs 3.x/4.x
402- * @return array
396+ * @return array<int|string, int|string>
403397 */
404398 public static function getFunctionNameTokens ()
405399 {
406400 if (defined ('Tokens::FUNCTION_NAME_TOKENS ' )) {
407401 return Tokens::FUNCTION_NAME_TOKENS ;
408402 }
409- if (isset (Tokens::$ functionNameTokens )) {
410- return Tokens::$ functionNameTokens ;
411- }
412- return [];
403+ return Tokens::$ functionNameTokens ;
413404 }
414405
415406 /**
416407 * Compatibility handler for phpcs 3.x/4.x
417- * @return array
408+ * @return array<int|string, int|string>
418409 */
419410 public static function getEmptyTokens ()
420411 {
421412 if (defined ('Tokens::EMPTY_TOKENS ' )) {
422413 return Tokens::EMPTY_TOKENS ;
423414 }
424- if (isset (Tokens::$ emptyTokens )) {
425- return Tokens::$ emptyTokens ;
426- }
427- return [];
415+ return Tokens::$ emptyTokens ;
428416 }
429417
430418 /**
431419 * Compatibility handler for phpcs 3.x/4.x
432- * @return array
420+ * @return array<int|string, int|string>
433421 */
434422 private static function getScopeModifiers ()
435423 {
436424 if (defined ('Tokens::SCOPE_MODIFIERS ' )) {
437425 return Tokens::SCOPE_MODIFIERS ;
438426 }
439- if (isset (Tokens::$ scopeModifiers )) {
440- return Tokens::$ scopeModifiers ;
441- }
442- return [];
427+ return Tokens::$ scopeModifiers ;
443428 }
444429
445430 /**
446431 * Compatibility handler for phpcs 3.x/4.x
447- * @param array $tokens
432+ * @param array<int|string, array<int|string, int|string|array<int|string, int|string>>> $tokens
448433 * @param int $tokenIndex
449434 * @return bool
450435 */
451436 private static function hasScopeOpener ($ tokens , $ tokenIndex )
452437 {
438+ /** @phpstan-ignore-next-line offsetAccess.invalidOffset - code is always int|string */
453439 if (defined ('Tokens::SCOPE_OPENERS ' ) && isset (Tokens::SCOPE_OPENERS [$ tokens [$ tokenIndex ]['code ' ]])) {
454440 return true ;
455441 }
456- if (isset (Tokens::$ scopeOpeners ) && isset (Tokens::$ scopeOpeners [$ tokens [$ tokenIndex ]['code ' ]])) {
442+ /** @phpstan-ignore-next-line property.notFound,offsetAccess.invalidOffset - property exists in PHPCS 3.x */
443+ if (isset (Tokens::$ scopeOpeners [$ tokens [$ tokenIndex ]['code ' ]])) {
457444 return true ;
458445 }
459446 return false ;
460447 }
461448
462449 /**
463450 * Compatibility handler for phpcs 3.x/4.x
464- * @param array $tokens
451+ * @param array<int|string, array<int|string, int|string|array<int|string, int|string>>> $tokens
465452 * @param int $tokenIndex
466453 * @return bool
467454 */
468455 private static function hasAssignmentToken ($ tokens , $ tokenIndex )
469456 {
457+ /** @phpstan-ignore-next-line offsetAccess.invalidOffset - code is always int|string */
470458 if (defined ('Tokens::ASSIGNMENT_TOKENS ' ) && isset (Tokens::ASSIGNMENT_TOKENS [$ tokens [$ tokenIndex ]['code ' ]])) {
471459 return true ;
472460 }
473- if (isset (Tokens::$ assignmentTokens ) && isset (Tokens::$ assignmentTokens [$ tokens [$ tokenIndex ]['code ' ]])) {
461+ /** @phpstan-ignore-next-line property.notFound,offsetAccess.invalidOffset - property exists in PHPCS 3.x */
462+ if (isset (Tokens::$ assignmentTokens [$ tokens [$ tokenIndex ]['code ' ]])) {
474463 return true ;
475464 }
476465 return false ;
@@ -1386,7 +1375,7 @@ public static function getFunctionIndexForFunctionCallArgument(File $phpcsFile,
13861375 return null ;
13871376 }
13881377 /**
1389- * @var array <int|string|null >
1378+ * @var list <int|string>
13901379 */
13911380 $ startingParenthesis = array_keys ($ token ['nested_parenthesis ' ]);
13921381 $ startOfArguments = end ($ startingParenthesis );
0 commit comments