Skip to content

Commit

Permalink
Fix rendering of pre 8.1 enums
Browse files Browse the repository at this point in the history
  • Loading branch information
sunkan committed Dec 29, 2024
1 parent 264b8bc commit 31508b8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Renderer/Php7Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function renderEnum(PhpEnum $enum): array
'if ($self) {',
['return $self;'],
'}',
'throw new ValueError(\'Enum not found\');',
'throw new \ValueError(\'Enum not found: \' . $value);',
], Type::fromString('self'));
$fromCtor->setStatic();
$enum->addMethod($fromCtor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Test
if ($self) {
return $self;
}
throw new ValueError('Enum not found');
throw new \ValueError('Enum not found: ' . $value);
}

public static function tryFrom(string $value): ?self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Test
if ($self) {
return $self;
}
throw new ValueError('Enum not found');
throw new \ValueError('Enum not found: ' . $value);
}

public static function tryFrom(string $value): ?self
Expand Down

0 comments on commit 31508b8

Please sign in to comment.