@@ -52,12 +52,13 @@ public function process(File $phpcsFile, $stackPtr): void
5252 // phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration
5353 // phpcs:enable Generic.Metrics.CyclomaticComplexity
5454
55- if ($ this ->shouldIgnore ($ phpcsFile , $ stackPtr )) {
55+ /** @var array<int, array<string, mixed>> $tokens */
56+ $ tokens = $ phpcsFile ->getTokens ();
57+
58+ if ($ this ->shouldIgnore ($ phpcsFile , $ stackPtr , $ tokens )) {
5659 return ;
5760 }
5861
59- /** @var array<int, array<string, mixed>> $tokens */
60- $ tokens = $ phpcsFile ->getTokens ();
6162 $ paramsStart = (int )($ tokens [$ stackPtr ]['parenthesis_opener ' ] ?? 0 );
6263 $ paramsEnd = (int )($ tokens [$ stackPtr ]['parenthesis_closer ' ] ?? 0 );
6364
@@ -91,15 +92,17 @@ public function process(File $phpcsFile, $stackPtr): void
9192 /**
9293 * @param File $phpcsFile
9394 * @param int $stackPtr
95+ * @param array<int, array<string, mixed>> $tokens
9496 * @return bool
9597 *
9698 * phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration
9799 */
98- private function shouldIgnore (File $ phpcsFile , $ stackPtr ): bool
100+ private function shouldIgnore (File $ phpcsFile , $ stackPtr, array $ tokens ): bool
99101 {
100102 // phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration
101103
102- $ name = $ phpcsFile ->getDeclarationName ($ stackPtr );
104+ $ tokenCode = $ tokens [$ stackPtr ]['code ' ] ?? '' ;
105+ $ name = ($ tokenCode !== T_FN ) ? ($ phpcsFile ->getDeclarationName ($ stackPtr ) ?: '' ) : '' ;
103106
104107 return PhpcsHelpers::functionIsArrayAccess ($ phpcsFile , $ stackPtr )
105108 || PhpcsHelpers::isHookClosure ($ phpcsFile , $ stackPtr )
0 commit comments