@@ -342,7 +342,7 @@ public static function functionDocBlockTags(
342
342
343
343
if (
344
344
!array_key_exists ($ position , $ tokens )
345
- || !in_array ($ tokens [$ position ]['code ' ], [T_FUNCTION , T_CLOSURE ], true )
345
+ || !in_array ($ tokens [$ position ]['code ' ], [T_FUNCTION , T_CLOSURE , T_FN ], true )
346
346
) {
347
347
return [];
348
348
}
@@ -480,7 +480,7 @@ public static function functionBody(File $file, int $position): string
480
480
/**
481
481
* @param File $file
482
482
* @param int $position
483
- * @return array {int, int}
483
+ * @return list {int, int}
484
484
*/
485
485
public static function functionBoundaries (File $ file , int $ position ): array
486
486
{
@@ -491,19 +491,13 @@ public static function functionBoundaries(File $file, int $position): array
491
491
return [-1 , -1 ];
492
492
}
493
493
494
- $ functionStart = (int )($ tokens [$ position ]['scope_opener ' ] ?? 0 );
495
- $ functionEnd = (int )($ tokens [$ position ]['scope_closer ' ] ?? 0 );
496
- if ($ functionStart <= 0 || $ functionEnd <= 0 || $ functionStart >= ($ functionEnd - 1 )) {
497
- return [-1 , -1 ];
498
- }
499
-
500
- return [$ functionStart , $ functionEnd ];
494
+ return static ::boundaries ($ tokens , $ position );
501
495
}
502
496
503
497
/**
504
498
* @param File $file
505
499
* @param int $position
506
- * @return array {int, int}
500
+ * @return list {int, int}
507
501
*/
508
502
public static function classBoundaries (File $ file , int $ position ): array
509
503
{
@@ -514,13 +508,7 @@ public static function classBoundaries(File $file, int $position): array
514
508
return [-1 , -1 ];
515
509
}
516
510
517
- $ start = (int )($ tokens [$ position ]['scope_opener ' ] ?? 0 );
518
- $ end = (int )($ tokens [$ position ]['scope_closer ' ] ?? 0 );
519
- if ($ start <= 0 || $ end <= 0 || $ start >= ($ end - 1 )) {
520
- return [-1 , -1 ];
521
- }
522
-
523
- return [$ start , $ end ];
511
+ return static ::boundaries ($ tokens , $ position );
524
512
}
525
513
526
514
/**
@@ -728,4 +716,20 @@ public static function isUntypedPsrMethod(File $file, int $position): bool
728
716
729
717
return false ;
730
718
}
719
+
720
+ /**
721
+ * @param array<int, array<string, mixed>> $tokens
722
+ * @param int $position
723
+ * @return list{int, int}
724
+ */
725
+ private static function boundaries (array $ tokens , int $ position ): array
726
+ {
727
+ $ start = (int )($ tokens [$ position ]['scope_opener ' ] ?? 0 );
728
+ $ end = (int )($ tokens [$ position ]['scope_closer ' ] ?? 0 );
729
+ if ($ start <= 0 || $ end <= 0 || $ start >= ($ end - 1 )) {
730
+ return [-1 , -1 ];
731
+ }
732
+
733
+ return [$ start , $ end ];
734
+ }
731
735
}
0 commit comments