3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DIContainer { /** * @var array<string, callable> */ private array $registered; /** * @var array<string, object> */ private array $created; public function register(string $name, callable $factory): void { if (array_key_exists($name, $this->registered)) { throw new DIContainerException('Сервис с таким именем уже зарегистрирован.'); } $this->registered[$name] = $factory; } public function get(string $name): mixed { if (array_key_exists($name, $this->created)) { return $this->created[$name]; } elseif (array_key_exists($name, $this->registered)) { $object = call_user_func($this->registered[$name], $this); $this->created[$name] = $object; return $object; } else { throw new DIContainerException('Сервис с таким именем не зарегистрирован.'); } } }
Output for git.master_jit, git.master, rfc.property-hooks

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
53.56 ms | 405 KiB | 5 Q