3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (interface_exists('JsonSerializable', true) === false) { interface JsonSerializable { /** * (PHP 5 &gt;= 5.4.0)<br/> * Specify data which should be serialized to JSON * @link http://php.net/manual/en/jsonserializable.jsonserialize.php * @return mixed data which can be serialized by <b>json_encode</b>, * which is a value of any type other than a resource. */ function jsonSerialize (); } } /** * @package MXO_JSON */ abstract class MXO_JSON_Collection implements Countable, ArrayAccess, IteratorAggregate, JsonSerializable { protected $container = array(); public function __construct(array $init_array = array()) { $this->container = $init_array; } public function count() { return count($this->container); } public function offsetExists($offset) { return isset($this->container[$offset]); } public function offsetGet($offset) { return isset($this->container[$offset]) === true ? $this->container[$offset] : null; } public function getIterator() { return new ArrayIterator($this->container); } public function __clone() { $this->container = MXO_JSON::copy($this->container); } /** * returns result in raw format - for use with php's array functions * * @deprecated If you need this, consider adding more array-specific functions to MXO_JSON_Utils */ public function getRaw() { $result = array(); foreach ($this->container as $key => $element) { if ($element instanceof MXO_JSON_Collection) { $result[$key] = $element->getRaw(); } else { $result[$key] = $element; } } return $result; } /** * Like getRaw, but only converts this collection to an array; * deeper collections are left as-is. * * @deprecated If you need this, consider adding more array-specific functions to MXO_JSON_Utils */ public function getAsArray() { return $this->container; } public function keyExists($key) { return array_key_exists($key, $this->container); } public function keys() { return array_keys($this->container); } public function values() { return array_values($this->container); } public function sort($sort_flags = null) { return sort($this->container, $sort_flags); } public function rsort($sort_flags = null) { return rsort($this->container, $sort_flags); } abstract public function natsort(); abstract public function natcasesort(); public function usort($value_compare_func) { return usort($this->container, $value_compare_func); } abstract public function map($callback); abstract public function filter($callback); abstract public function merge($obj); public function search($needle) { return array_search($needle, $this->container, true); } abstract public function intersect($obj); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MXO_JSON_Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/F7pSJ on line 26 Deprecated: Return type of MXO_JSON_Collection::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/F7pSJ on line 30 Deprecated: Return type of MXO_JSON_Collection::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/F7pSJ on line 34 Deprecated: Return type of MXO_JSON_Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/F7pSJ on line 38

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:
38.33 ms | 403 KiB | 8 Q