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