3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * Slim Framework (https://slimframework.com) * * @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License) */ namespace Slim; use ArrayIterator; use ArrayAccess; use Countable; use IteratorAggregate; interface CollectionInterface extends ArrayAccess, Countable, IteratorAggregate { /** * Set collection item * * @param string $key The data key * @param mixed $value The data value */ public function set($key, $value); /** * Get collection item for key * * @param string $key The data key * @param mixed $default The default value to return if data key does not exist * * @return mixed The key's value, or the default value */ public function get($key, $default = null); /** * Add item to collection, replacing existing items with the same data key * * @param array $items Key-value array of data to append to this collection */ public function replace(array $items); /** * Get all items in collection * * @return array The collection's source data */ public function all(); /** * Does this collection have a given key? * * @param string $key The data key * * @return bool */ public function has($key); /** * Remove item from collection * * @param string $key The data key */ public function remove($key); /** * Remove all items from collection */ public function clear(); } /** * Collection * * This class provides a common interface used by many other * classes in a Slim application that manage "collections" * of data that must be inspected and/or manipulated */ class Collection implements CollectionInterface { /** * The source data * * @var array */ protected $data = []; /** * @param array $items Pre-populate collection with this key-value array */ public function __construct(array $items = []) { $this->replace($items); } /** * {@inheritdoc} */ public function set($key, $value) { $this->data[$key] = $value; } /** * {@inheritdoc} */ public function get($key, $default = null) { return $this->has($key) ? $this->data[$key] : $default; } /** * {@inheritdoc} */ public function replace(array $items) { foreach ($items as $key => $value) { $this->set($key, $value); } } /** * {@inheritdoc} */ public function all() { return $this->data; } /** * Get collection keys * * @return array The collection's source data keys */ public function keys() { return array_keys($this->data); } /** * {@inheritdoc} */ public function has($key) { return array_key_exists($key, $this->data); } /** * {@inheritdoc} */ public function remove($key) { unset($this->data[$key]); } /** * {@inheritdoc} */ public function clear() { $this->data = []; } /** * Does this collection have a given key? * * @param string $key The data key * * @return bool */ public function offsetExists($key): bool { return $this->has($key); } /** * Get collection item for key * * @param string $key The data key * * @return mixed The key's value, or the default value */ #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->get($key); } /** * Set collection item * * @param string $key The data key * @param mixed $value The data value */ #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->set($key, $value); } /** * Remove item from collection * * @param string $key The data key */ #[\ReturnTypeWillChange] public function offsetUnset($key) { $this->remove($key); } /** * Get number of items in collection * * @return int */ public function count(): int { return count($this->data); } /** * Get collection iterator * * @return ArrayIterator|\Traversable */ public function getIterator(): \Traversable { return new ArrayIterator($this->data); } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.70.0080.00916.64
8.5.60.0090.00616.80
8.5.50.0100.00816.49
8.5.30.0060.01221.18
8.5.20.0060.00617.87
8.5.10.0130.00916.30
8.5.00.0120.01019.94
8.4.220.0090.01219.43
8.4.210.0100.01219.54
8.4.180.0060.00525.49
8.4.170.0150.00623.88
8.4.160.0120.01123.90
8.4.150.0070.00416.80
8.4.140.0120.00917.30
8.4.130.0150.00617.76
8.4.120.0110.00920.68
8.4.110.0090.01122.80
8.4.100.0160.00417.77
8.4.90.0100.01117.83
8.4.80.0130.00617.55
8.4.70.0080.00817.93
8.4.60.0090.01017.73
8.4.50.0130.00818.61
8.4.40.0140.00717.56
8.4.30.0130.00322.14
8.4.20.0160.00317.84
8.4.10.0050.00319.65
8.3.310.0130.00718.44
8.3.300.0100.01120.68
8.3.290.0080.01222.38
8.3.280.0060.00516.21
8.3.270.0110.00816.59
8.3.260.0090.01016.54
8.3.250.0130.00618.99
8.3.240.0150.00516.74
8.3.230.0030.00516.51
8.3.220.0140.00417.08
8.3.210.0130.00716.43
8.3.200.0130.00716.51
8.3.190.0100.00916.74
8.3.180.0130.00616.73
8.3.170.0060.01318.88
8.3.160.0130.00316.61
8.3.150.0000.00718.80
8.3.140.0110.00317.08
8.3.130.0030.00618.60
8.3.120.0130.00718.94
8.3.110.0030.00620.94
8.3.100.0080.00324.06
8.3.90.0000.00826.77
8.3.80.0040.00717.97
8.3.70.0150.00018.46
8.3.60.0120.00316.62
8.3.50.0130.01016.45
8.3.40.0070.01320.29
8.3.30.0070.00721.91
8.3.20.0000.00724.18
8.3.10.0080.00024.66
8.3.00.0100.00026.16
8.2.300.0090.01218.76
8.2.290.0110.00820.36
8.2.280.0090.00917.99
8.2.270.0090.00917.25
8.2.260.0160.00318.36
8.2.250.0030.00716.77
8.2.240.0070.00716.86
8.2.230.0080.00022.58
8.2.220.0110.00037.54
8.2.210.0040.00426.77
8.2.200.0030.00716.38
8.2.190.0090.00618.29
8.2.180.0120.00316.75
8.2.170.0120.00318.83
8.2.160.0090.00922.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00018.71
8.2.110.0070.01520.51
8.2.100.0130.00918.97
8.2.90.0170.00718.85
8.2.80.0200.00318.47
8.2.70.0140.00718.78
8.2.60.0100.01318.64
8.2.50.0070.01718.59
8.2.40.0110.01418.84
8.2.30.0160.00618.66
8.2.20.0100.00718.70
8.2.10.0180.00319.13
8.2.00.0100.01019.07
8.1.340.0110.00917.54
8.1.330.0130.00516.58
8.1.320.0100.00716.11
8.1.310.0030.00618.25
8.1.300.0030.00617.88
8.1.290.0070.00330.84
8.1.280.0090.00925.92
8.1.270.0040.00424.66
8.1.260.0050.00326.35
8.1.250.0000.01428.09
8.1.240.0110.01118.62
8.1.230.0120.00618.61
8.1.220.0140.00718.32
8.1.210.0140.00319.86
8.1.200.0100.01318.62
8.1.190.0070.00318.30
8.1.180.0060.00318.19
8.1.170.0100.01018.35
8.1.160.0030.00718.69
8.1.150.0000.00920.38
8.1.140.0110.00318.21
8.1.130.0090.00918.35
8.1.120.0060.00618.55
8.1.110.0030.00718.60
8.1.100.0100.01018.50
8.1.90.0120.00618.60
8.1.80.0070.00318.56
8.1.70.0150.00618.58
8.1.60.0050.00518.74
8.1.50.0060.00318.55
8.1.40.0120.00418.88
8.1.30.0070.00320.63
8.1.20.0050.00520.40
8.1.10.0090.00318.42
8.1.00.0030.00718.47
8.0.300.0040.00417.78
8.0.290.0120.00017.72
8.0.280.0060.00317.88
8.0.270.0030.01417.85
8.0.260.0050.00517.78
8.0.250.0030.00617.70
8.0.240.0030.00717.71
8.0.230.0070.01118.29
8.0.220.0070.00317.77
8.0.210.0060.00317.82
8.0.200.0150.00317.89
8.0.190.0060.00317.75
8.0.180.0040.00417.86
8.0.170.0070.00317.83
8.0.160.0150.00417.66
8.0.150.0030.00617.77
8.0.140.0090.00017.76
8.0.130.0110.00818.17
8.0.120.0180.00417.83
8.0.110.0030.00718.01
8.0.100.0060.00317.88
8.0.90.0090.00017.75
8.0.80.0140.00517.66
8.0.70.0100.01017.63
8.0.60.0100.00717.83
8.0.50.0080.00817.83
8.0.30.0070.01017.96
8.0.20.0100.00717.91
8.0.10.0060.00317.86
7.4.00.0100.01018.29
7.2.340.0110.01017.34
7.0.330.0210.01315.89
7.0.00.0160.00616.85
5.6.400.0180.00316.56
5.5.380.0090.00716.67

preferences:
80.43 ms | 1137 KiB | 5 Q