Skip to content

Commit

Permalink
Add test for return type fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Jun 9, 2024
1 parent 1f2dc8d commit c856125
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/CodeCleaner/ReturnTypePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
16 changes: 16 additions & 0 deletions test/CodeCleaner/ReturnTypePassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit c856125

Please sign in to comment.