diff --git a/src/CodeCleaner/ReturnTypePass.php b/src/CodeCleaner/ReturnTypePass.php index 9e170144..5d718cdb 100644 --- a/src/CodeCleaner/ReturnTypePass.php +++ b/src/CodeCleaner/ReturnTypePass.php @@ -105,11 +105,7 @@ private function typeName(Node $node): string return \strtolower($node->type->name); } - if ($node instanceof Identifier) { - return \strtolower($node->name); - } - - if ($node instanceof Name) { + if ($node instanceof Identifier || $node instanceof Name) { return \strtolower($node->name); } diff --git a/test/CodeCleaner/ReturnTypePassTest.php b/test/CodeCleaner/ReturnTypePassTest.php index 0b9803e7..f74b7fe4 100644 --- a/test/CodeCleaner/ReturnTypePassTest.php +++ b/test/CodeCleaner/ReturnTypePassTest.php @@ -26,6 +26,22 @@ public function getReady() $this->setPass(new ReturnTypePass()); } + /** + * @dataProvider happyPaths + */ + public function testHappyPath($code) + { + $result = $this->parseAndTraverse($code); + $this->assertIsArray($result); + } + + public function happyPaths() + { + return [ + ['$x = function(): DateTime { return new DateTime(); };'], + ]; + } + /** * @dataProvider missingReturns */