3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class EnumerationBase { const NONE = null; /** * * @var mixed */ private $value; /** * * @param type $name * @param array $argumentArray * @return EnumerationBase */ final public static function __callStatic($name, array $argumentArray) { return new static(constant("static::{$name}")); } /** * * @param object $value */ final private function __construct($value) { $this->value = $value; } final private function __clone() { ; } /** * * @param EnumerationBase $enumeration * @return bool */ final public function isEqualTo(EnumerationBase $enumeration) { return ($this instanceof $enumeration) && ($this->value === $enumeration->value); } } /** * * @method FooEnumeration ONE() * @method FooEnumeration TWO() */ final class FooEnumeration extends EnumerationBase { const ONE = 1; const TWO = 2; } /** * * @method BarEnumeration ONE() * @method BarEnumeration TWO() */ final class BarEnumeration extends EnumerationBase { const ONE = 1; const TWO = 2; } var_dump(FooEnumeration::ONE()->isEqualTo(FooEnumeration::ONE())); var_dump(true); echo '----------------' . PHP_EOL; var_dump(FooEnumeration::ONE()->isEqualTo(FooEnumeration::TWO())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(FooEnumeration::TWO()->isEqualTo(FooEnumeration::ONE())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(FooEnumeration::TWO()->isEqualTo(FooEnumeration::TWO())); var_dump(true); echo '----------------' . PHP_EOL; var_dump(FooEnumeration::ONE()->isEqualTo(BarEnumeration::ONE())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(FooEnumeration::ONE()->isEqualTo(BarEnumeration::TWO())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(FooEnumeration::TWO()->isEqualTo(BarEnumeration::ONE())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(FooEnumeration::TWO()->isEqualTo(BarEnumeration::TWO())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::ONE()->isEqualTo(FooEnumeration::ONE())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::ONE()->isEqualTo(FooEnumeration::TWO())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::TWO()->isEqualTo(FooEnumeration::ONE())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::TWO()->isEqualTo(FooEnumeration::TWO())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::ONE()->isEqualTo(BarEnumeration::ONE())); var_dump(true); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::ONE()->isEqualTo(BarEnumeration::TWO())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::TWO()->isEqualTo(BarEnumeration::ONE())); var_dump(false); echo '----------------' . PHP_EOL; var_dump(BarEnumeration::TWO()->isEqualTo(BarEnumeration::TWO())); var_dump(true); echo '----------------' . PHP_EOL;
Output for 5.3.0 - 7.1.0
bool(true) bool(true) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(true) bool(true) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(true) bool(true) ---------------- bool(false) bool(false) ---------------- bool(false) bool(false) ---------------- bool(true) bool(true) ----------------
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/YAOG8 on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/YAOG8 on line 20
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/YAOG8 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CLASS in /in/YAOG8 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/YAOG8 on line 3
Process exited with code 255.