3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DIContainer1 implements ArrayAccess { private array $registered; private array $created; public function offsetSet(mixed $offset, mixed $value): void { if (is_null($offset)) { throw new DIContainerException('Обязательно должен быть указан ключ.'); } if (array_key_exists($offset, $this->registered)) { throw new DIContainerException('Нельзя использовать один и тот же ключ для нескольких элементов.'); } $this->registered[$offset] = $value; } public function offsetExists(mixed $offset): bool { return isset($this->registered[$offset]); } public function offsetUnset(mixed $offset): void { unset($this->registered[$offset]); unset($this->created[$offset]); } public function offsetGet(mixed $offset): mixed { if (array_key_exists($offset, $this->created)) { return $this->created[$offset]; } elseif (array_key_exists($offset, $this->registered)) { $object = $this->registered[$offset]($this); $this->created[$offset] = $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:
48.1 ms | 405 KiB | 5 Q