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_.
Version: 4.0.3
Bug Description
When using
EnumType::fromwith argumentwithBodiesset totrue, the extracted enum method has no body.Steps To Reproduce
gives
Expected Behavior
Possible Solution
Condition here in Extractor
php-generator/src/PhpGenerator/Extractor.php
Line 69 in ce44913
should also check if node is instance of
Node\Stmt\Enum_.