@@ -52,12 +52,13 @@ public function process(File $phpcsFile, $stackPtr): void
52
52
// phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration
53
53
// phpcs:enable Generic.Metrics.CyclomaticComplexity
54
54
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 )) {
56
59
return ;
57
60
}
58
61
59
- /** @var array<int, array<string, mixed>> $tokens */
60
- $ tokens = $ phpcsFile ->getTokens ();
61
62
$ paramsStart = (int )($ tokens [$ stackPtr ]['parenthesis_opener ' ] ?? 0 );
62
63
$ paramsEnd = (int )($ tokens [$ stackPtr ]['parenthesis_closer ' ] ?? 0 );
63
64
@@ -91,15 +92,17 @@ public function process(File $phpcsFile, $stackPtr): void
91
92
/**
92
93
* @param File $phpcsFile
93
94
* @param int $stackPtr
95
+ * @param array<int, array<string, mixed>> $tokens
94
96
* @return bool
95
97
*
96
98
* phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration
97
99
*/
98
- private function shouldIgnore (File $ phpcsFile , $ stackPtr ): bool
100
+ private function shouldIgnore (File $ phpcsFile , $ stackPtr, array $ tokens ): bool
99
101
{
100
102
// phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration
101
103
102
- $ name = $ phpcsFile ->getDeclarationName ($ stackPtr );
104
+ $ tokenCode = $ tokens [$ stackPtr ]['code ' ] ?? '' ;
105
+ $ name = ($ tokenCode !== T_FN ) ? ($ phpcsFile ->getDeclarationName ($ stackPtr ) ?: '' ) : '' ;
103
106
104
107
return PhpcsHelpers::functionIsArrayAccess ($ phpcsFile , $ stackPtr )
105
108
|| PhpcsHelpers::isHookClosure ($ phpcsFile , $ stackPtr )
0 commit comments