How can I specify an argument type to take any enum value?
Something like function processEnum(enum $value) would be ideal, however nothing seems to exist?
enum Numbers: int {
case FIRST = 1;
case SECOND = 2;
}
enum Foo: string {
case BAR = 'bar';
}
function printEnum($enumValue) {
echo $enumValue->value;
}
printEnum(Numbers::FIRST); // 1
printEnum(Foo::BAR); // 'bar'
printEnum('fail'); // I want to reject this!
Additionally it would be nice to separate backed vs non-backed enums or additionally backed types; enums that are backed as strings for example.