Browse Source

PhpdocTypesFixer - fix recognising callable without return type

Kuba Werłos 3 years ago
parent
commit
76e50220d8

+ 1 - 1
src/DocBlock/TypeExpression.php

@@ -306,7 +306,7 @@ final class TypeExpression
         if ('' !== ($matches['callable'] ?? '')) {
             $this->parseCommaSeparatedInnerTypes(
                 $index + \strlen($matches['callable_start']),
-                $matches['callable_arguments']
+                $matches['callable_arguments'] ?? ''
             );
 
             $return = $matches['callable_return'] ?? null;

+ 2 - 0
tests/DocBlock/TypeExpressionTest.php

@@ -125,6 +125,8 @@ final class TypeExpressionTest extends TestCase
 
         yield ['TheCollection<callable(Foo, Bar,Baz): Foo[]>|string[]|null', ['TheCollection<callable(Foo, Bar,Baz): Foo[]>', 'string[]', 'null']];
 
+        yield ['Closure()', ['Closure()']];
+
         yield ['Closure(string)', ['Closure(string)']];
 
         yield ['array  <  int   , callable  (  string  )  :   bool  >', ['array  <  int   , callable  (  string  )  :   bool  >']];

+ 2 - 0
tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php

@@ -296,10 +296,12 @@ EOF;
     {
         yield 'callable' => [
             '<?php /**
+                    * @param callable() $a
                     * @param callable(): void $b
                     * @param callable(bool, int, string): float $c
                     */',
             '<?php /**
+                    * @param CALLABLE() $a
                     * @param Callable(): VOID $b
                     * @param CALLABLE(BOOL, INT, STRING): FLOAT $c
                     */',