Skip to content

Commit 31508b8

Browse files
committed
Fix rendering of pre 8.1 enums
1 parent 264b8bc commit 31508b8

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/Renderer/Php7Renderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function renderEnum(PhpEnum $enum): array
144144
'if ($self) {',
145145
['return $self;'],
146146
'}',
147-
'throw new ValueError(\'Enum not found\');',
147+
'throw new \ValueError(\'Enum not found: \' . $value);',
148148
], Type::fromString('self'));
149149
$fromCtor->setStatic();
150150
$enum->addMethod($fromCtor);

tests/Renderer/resources/PhpEnumTest.testPhp7.backed.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class Test
1616
if ($self) {
1717
return $self;
1818
}
19-
throw new ValueError('Enum not found');
19+
throw new \ValueError('Enum not found: ' . $value);
2020
}
2121

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

tests/Renderer/resources/PhpEnumTest.testPhp7.simple.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class Test
1616
if ($self) {
1717
return $self;
1818
}
19-
throw new ValueError('Enum not found');
19+
throw new \ValueError('Enum not found: ' . $value);
2020
}
2121

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

0 commit comments

Comments
 (0)