3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class EventStatus { const SUCCESS = 'success'; const STOPPED = 'stopped'; const FAILED = 'failed'; private static $validStatuses = [ static::SUCCESS, static::STOPPED, static::FAILED ]; private $status = self::SUCCESS; public function __construct($aStatus = self::SUCCESS) { $this->validateStatus($aStatus); $this->status = (string) $aStatus; } public static function __callStatic($aStatus, $arguments = []) { return new static($aStatus); } public function isSuccess() { return ($this->status == self::SUCCESS): } public function isStopped() { return ($this->status == self::STOPPED); } public function isFailed() { return ($this->status == self::FAILED); } private function validateStatus($aStatus) { if (!in_array(str_to_lower($aStatus), static::$validStatuses)) { throw new DomainException("Invalid event status [$aStatus]"); } } } var_dump(EventStatus::Failed());
Output for 5.4.0 - 5.4.24
Fatal error: "static::" is not allowed in compile-time constants in /in/VKE3A on line 10
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[' in /in/VKE3A on line 9
Process exited with code 255.