declare(strict_types=1);
enum Status: string {
case OK = 'ok';
case FAIL = 'fail';
}
function check(Status $s): void {
echo $s->value;
}
check(Status::OK); // OK
check("ok"); // TypeError
/*
run:
ERROR!
ok
Fatal error: Uncaught TypeError: check(): Argument #1 ($s) must be of type Status, string given
*/