@@ -93,7 +93,7 @@ public static function findContainingOpeningBracket(File $phpcsFile, $stackPtr)
93
93
$ tokens = $ phpcsFile ->getTokens ();
94
94
if (isset ($ tokens [$ stackPtr ]['nested_parenthesis ' ])) {
95
95
/**
96
- * @var array <int|string|null >
96
+ * @var list <int|string>
97
97
*/
98
98
$ openPtrs = array_keys ($ tokens [$ stackPtr ]['nested_parenthesis ' ]);
99
99
return (int )end ($ openPtrs );
@@ -364,9 +364,6 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr)
364
364
if (self ::findContainingOpeningBracket ($ phpcsFile , $ nextPtr ) === $ openPtr ) {
365
365
// Comma is at our level of brackets, it's an argument delimiter.
366
366
$ range = range ($ lastArgComma + 1 , $ nextPtr - 1 );
367
- $ range = array_filter ($ range , function ($ element ) {
368
- return is_int ($ element );
369
- });
370
367
array_push ($ argPtrs , $ range );
371
368
$ lastArgComma = $ nextPtr ;
372
369
}
@@ -384,93 +381,85 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr)
384
381
385
382
/**
386
383
* Compatibility handler for phpcs 3.x/4.x
387
- * @return array
384
+ * @return array<int|string, int|string>
388
385
*/
389
386
public static function getOoScopeTokens ()
390
387
{
391
388
if (defined ('Tokens::OO_SCOPE_TOKENS ' )) {
392
389
return Tokens::OO_SCOPE_TOKENS ;
393
390
}
394
- if (isset (Tokens::$ ooScopeTokens )) {
395
- return Tokens::$ ooScopeTokens ;
396
- }
397
- return [];
391
+ return Tokens::$ ooScopeTokens ;
398
392
}
399
393
400
394
/**
401
395
* Compatibility handler for phpcs 3.x/4.x
402
- * @return array
396
+ * @return array<int|string, int|string>
403
397
*/
404
398
public static function getFunctionNameTokens ()
405
399
{
406
400
if (defined ('Tokens::FUNCTION_NAME_TOKENS ' )) {
407
401
return Tokens::FUNCTION_NAME_TOKENS ;
408
402
}
409
- if (isset (Tokens::$ functionNameTokens )) {
410
- return Tokens::$ functionNameTokens ;
411
- }
412
- return [];
403
+ return Tokens::$ functionNameTokens ;
413
404
}
414
405
415
406
/**
416
407
* Compatibility handler for phpcs 3.x/4.x
417
- * @return array
408
+ * @return array<int|string, int|string>
418
409
*/
419
410
public static function getEmptyTokens ()
420
411
{
421
412
if (defined ('Tokens::EMPTY_TOKENS ' )) {
422
413
return Tokens::EMPTY_TOKENS ;
423
414
}
424
- if (isset (Tokens::$ emptyTokens )) {
425
- return Tokens::$ emptyTokens ;
426
- }
427
- return [];
415
+ return Tokens::$ emptyTokens ;
428
416
}
429
417
430
418
/**
431
419
* Compatibility handler for phpcs 3.x/4.x
432
- * @return array
420
+ * @return array<int|string, int|string>
433
421
*/
434
422
private static function getScopeModifiers ()
435
423
{
436
424
if (defined ('Tokens::SCOPE_MODIFIERS ' )) {
437
425
return Tokens::SCOPE_MODIFIERS ;
438
426
}
439
- if (isset (Tokens::$ scopeModifiers )) {
440
- return Tokens::$ scopeModifiers ;
441
- }
442
- return [];
427
+ return Tokens::$ scopeModifiers ;
443
428
}
444
429
445
430
/**
446
431
* Compatibility handler for phpcs 3.x/4.x
447
- * @param array $tokens
448
- * @param int $tokenIndex
432
+ * @param array<int|string, array<int|string, int|string|array<int|string, int|string>>> $tokens
433
+ * @param int $tokenIndex
449
434
* @return bool
450
435
*/
451
436
private static function hasScopeOpener ($ tokens , $ tokenIndex )
452
437
{
438
+ /** @phpstan-ignore-next-line offsetAccess.invalidOffset - code is always int|string */
453
439
if (defined ('Tokens::SCOPE_OPENERS ' ) && isset (Tokens::SCOPE_OPENERS [$ tokens [$ tokenIndex ]['code ' ]])) {
454
440
return true ;
455
441
}
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 ' ]])) {
457
444
return true ;
458
445
}
459
446
return false ;
460
447
}
461
448
462
449
/**
463
450
* Compatibility handler for phpcs 3.x/4.x
464
- * @param array $tokens
465
- * @param int $tokenIndex
451
+ * @param array<int|string, array<int|string, int|string|array<int|string, int|string>>> $tokens
452
+ * @param int $tokenIndex
466
453
* @return bool
467
454
*/
468
455
private static function hasAssignmentToken ($ tokens , $ tokenIndex )
469
456
{
457
+ /** @phpstan-ignore-next-line offsetAccess.invalidOffset - code is always int|string */
470
458
if (defined ('Tokens::ASSIGNMENT_TOKENS ' ) && isset (Tokens::ASSIGNMENT_TOKENS [$ tokens [$ tokenIndex ]['code ' ]])) {
471
459
return true ;
472
460
}
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 ' ]])) {
474
463
return true ;
475
464
}
476
465
return false ;
@@ -1386,7 +1375,7 @@ public static function getFunctionIndexForFunctionCallArgument(File $phpcsFile,
1386
1375
return null ;
1387
1376
}
1388
1377
/**
1389
- * @var array <int|string|null >
1378
+ * @var list <int|string>
1390
1379
*/
1391
1380
$ startingParenthesis = array_keys ($ token ['nested_parenthesis ' ]);
1392
1381
$ startOfArguments = end ($ startingParenthesis );
0 commit comments