<?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());
You have javascript disabled. You will not be able to edit any code.