3v4l.org

run code in 300+ PHP versions simultaneously
<?php // https://github.com/bootgly/bootgly/blob/c54e0d585869dca734d301000cee79401640e749/Bootgly/CLI/Terminal/Output/Text.php#L329-L336 // https://github.com/bootgly/bootgly/blob/c54e0d585869dca734d301000cee79401640e749/Bootgly/ABI/Configs/Set.php#L14-L26 enum Colors : int { public function __call(string $name, array $arguments) { static $value; return match ($name) { 'get' => $value ?? $this, // $this->value; 'set' => $value = $this, // $this->value = $this; // @ PHP team: Why readonly here??? default => $this }; } case Default = 1; case Bright = 2; } function printSomething(Colors $colors, string $message): void { echo sprintf("I will print %s in %s colors\n", $message, $colors->get()->name); } Colors::Default->set(); printSomething(Colors::Bright, 'Hello World'); Colors::Bright->set(); printSomething(Colors::Default, 'Hello World');

preferences:
27.77 ms | 404 KiB | 5 Q