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