3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); enum Foo: int { case A = 1; case B = 2; } var_dump(Foo::A > Foo::B); // I expect an error here as it is always false (enum cases are not comparable and always return false) var_dump(Foo::A < Foo::B); // I expect an error here as it is always false (enum cases are not comparable and always return false) var_dump(Foo::A === Foo::B); // OK var_dump(Foo::A == Foo::B); // I expect an error here as it is always false (enum cases are not comparable and always return false) var_dump(Foo::A === Foo::A); // I expect an error here as it is always true var_dump(Foo::A->value > Foo::B->value); // OK var_dump(Foo::A->value < Foo::B->value); // OK var_dump(Foo::A->value === Foo::B->value); // OK var_dump(Foo::A->value == Foo::B->value); // I'd probably expect an error here as well as always false var_dump(Foo::A->value === Foo::A->value); // I'd probably expect an error here as well as this is always true
Output for 8.1.5
bool(false) bool(false) bool(false) bool(false) bool(true) bool(false) bool(true) bool(false) bool(false) bool(true)

preferences:
146.71 ms | 1399 KiB | 8 Q