blob: 3f35bef64f55aa97bfe5b4a53c66fcccdda7a3f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
--TEST--
BackedEnum::from() reject invalid type
--FILE--
<?php
enum Suit: string {
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
try {
var_dump(Suit::from(42));
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
enum Foo: int {
case Bar = 0;
case Baz = 1;
}
try {
var_dump(Foo::from('H'));
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
"42" is not a valid backing value for enum "Suit"
Foo::from(): Argument #1 ($value) must be of type int, string given
|