@@ -342,7 +342,7 @@ public static function functionDocBlockTags(
342342
343343 if (
344344 !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 )
346346 ) {
347347 return [];
348348 }
@@ -480,7 +480,7 @@ public static function functionBody(File $file, int $position): string
480480 /**
481481 * @param File $file
482482 * @param int $position
483- * @return array {int, int}
483+ * @return list {int, int}
484484 */
485485 public static function functionBoundaries (File $ file , int $ position ): array
486486 {
@@ -491,19 +491,13 @@ public static function functionBoundaries(File $file, int $position): array
491491 return [-1 , -1 ];
492492 }
493493
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 );
501495 }
502496
503497 /**
504498 * @param File $file
505499 * @param int $position
506- * @return array {int, int}
500+ * @return list {int, int}
507501 */
508502 public static function classBoundaries (File $ file , int $ position ): array
509503 {
@@ -514,13 +508,7 @@ public static function classBoundaries(File $file, int $position): array
514508 return [-1 , -1 ];
515509 }
516510
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 );
524512 }
525513
526514 /**
@@ -728,4 +716,20 @@ public static function isUntypedPsrMethod(File $file, int $position): bool
728716
729717 return false ;
730718 }
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+ }
731735}
0 commit comments