3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Foo { case Bar; private function &getState(): array { static $state = []; return $state; } public function increment(): void { $this->getState()[$this->name]['count'] ??= 0; ++$this->getState()[$this->name]['count']; } public function getCount(): int { return $this->getState()[$this->name]['count'] ?? 0; } } Foo::Bar->increment(); var_dump( Foo::Bar->getCount());
Output for 8.1.0 - 8.1.32, 8.2.0 - 8.2.28, 8.3.0 - 8.3.22, 8.4.1 - 8.4.8
int(1)

preferences:
57.39 ms | 406 KiB | 5 Q