-
-
Notifications
You must be signed in to change notification settings - Fork 147
Closed
Description
Version: 4.0.3
Bug Description
When using EnumType::from
with argument withBodies
set to true
, the extracted enum method has no body.
Steps To Reproduce
<?php
require_once __DIR__ . "/vendor/autoload.php";
enum Color
{
case Red;
case Blue;
case Green;
public function getColor(): string
{
return $this->name;
}
}
echo \Nette\PhpGenerator\EnumType::from('Color', withBodies: true);
gives
enum Color
{
case Red;
case Blue;
case Green;
public function getColor(): string
{
}
}
Expected Behavior
enum Color
{
case Red;
case Blue;
case Green;
public function getColor(): string
{
return $this->name;
}
}
Possible Solution
Condition here in Extractor
fn(Node $node) => ($node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Trait_) |
should also check if node is instance of
Node\Stmt\Enum_
.Metadata
Metadata
Assignees
Labels
No labels