3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @extends ArrayObject<string, mixed> */ final class TypedArrayObject extends ArrayObject { public function getString(string $name): string { $value = $this[$name] ?? null; if (!is_string($value)) { throw new ValueError('Value at "' . $name . '" is not a string.'); } return $value; } public function getInteger(string $name): int { $value = $this[$name] ?? null; if (!is_int($value)) { throw new ValueError('Value at "' . $name . '" is not an integer.'); } return $value; } } $foo = new TypedArrayObject([ 'a' => 'hello', 'b' => 5, ]); $int = $foo->getInteger('b'); $string = $foo->getString('a');
Output for git.master, git.master_jit, 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:
52.87 ms | 401 KiB | 8 Q