Browse Source

bug: NativeFunctionTypeDeclarationCasingFixer - do not require T_STRING present in code (#6812)

Kuba Werłos 2 years ago
parent
commit
6e461ae5ae

+ 1 - 1
src/Fixer/Casing/NativeFunctionTypeDeclarationCasingFixer.php

@@ -118,7 +118,7 @@ final class NativeFunctionTypeDeclarationCasingFixer extends AbstractFixer
      */
     public function isCandidate(Tokens $tokens): bool
     {
-        return $tokens->isAllTokenKindsFound([T_FUNCTION, T_STRING]);
+        return $tokens->isTokenKindFound(T_FUNCTION);
     }
 
     /**

+ 4 - 0
tests/Fixer/Casing/NativeFunctionTypeDeclarationCasingFixerTest.php

@@ -128,6 +128,10 @@ function Foo(INTEGER $a) {}
                 '<?php function Foo(object $A): void {}',
                 '<?php function Foo(OBJECT $A): VOID {}',
             ],
+            [
+                '<?php return function (callable $c) {};',
+                '<?php return function (CALLABLE $c) {};',
+            ],
         ];
     }