1--TEST--
2Backed enums reject duplicate int values
3--FILE--
4<?php
5
6enum Foo: int {
7    case Bar = 0;
8    case Baz = 0;
9}
10
11try {
12    var_dump(Foo::Bar);
13} catch (Error $e) {
14    echo $e->getMessage(), "\n";
15}
16
17try {
18    var_dump(Foo::Bar);
19} catch (Error $e) {
20    echo $e->getMessage(), "\n";
21}
22
23try {
24    var_dump(Foo::from(42));
25} catch (Error $e) {
26    echo $e->getMessage(), "\n";
27}
28
29try {
30    var_dump(Foo::tryFrom('bar'));
31} catch (Error $e) {
32    echo $e->getMessage(), "\n";
33}
34
35?>
36--EXPECT--
37Duplicate value in enum Foo for cases Bar and Baz
38Duplicate value in enum Foo for cases Bar and Baz
39Duplicate value in enum Foo for cases Bar and Baz
40Foo::tryFrom(): Argument #1 ($value) must be of type int, string given
41