diff --git a/composer.json b/composer.json index 62295dc1..0b454af4 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": "^8.0 || ^7.4", "ext-json": "*", "ext-tokenizer": "*", - "nikic/php-parser": "^5.0 || ^4.0", + "nikic/php-parser": "^4.0", "symfony/console": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4", "symfony/var-dumper": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4" }, 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'); } }