diff --git a/src/CodeCleaner/ReturnTypePass.php b/src/CodeCleaner/ReturnTypePass.php index c9894fbd..05f54aa4 100644 --- a/src/CodeCleaner/ReturnTypePass.php +++ b/src/CodeCleaner/ReturnTypePass.php @@ -15,6 +15,7 @@ use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Identifier; +use PhpParser\Node\Name; use PhpParser\Node\NullableType; use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Return_; @@ -108,6 +109,10 @@ private function typeName(Node $node): string return \strtolower($node->name); } + if ($node instanceof Name) { + return strtolower($node->toString()); + } + throw new \InvalidArgumentException('Unable to find type name'); } }