From 2201595884cc84157c23159cccd73d9740f978d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Sch=C3=A4fer?= Date: Wed, 5 Jun 2024 20:24:08 +0200 Subject: [PATCH] fix "Unable to find type name" when creating closure --- src/CodeCleaner/ReturnTypePass.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CodeCleaner/ReturnTypePass.php b/src/CodeCleaner/ReturnTypePass.php index c9894fbd..9e170144 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->name); + } + throw new \InvalidArgumentException('Unable to find type name'); } }