3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * Provides a property based interface to an array. * The data are read-only unless $allowModifications is set to true * on construction. * * Implements Countable, Iterator and ArrayAccess * to facilitate easy access to the data. */ class Config implements Countable, Iterator, ArrayAccess { /** * Whether modifications to configuration data are allowed. * * @var bool */ protected $allowModifications; /** * Number of elements in configuration data. * * @var int */ protected $count; /** * Data withing the configuration. * * @var array */ protected $data = array(); /** * Used when unsetting values during iteration to ensure we do not skip * the next element. * * @var bool */ protected $skipNextIteration; /** * Constructor. * * Data is read-only unless $allowModifications is set to true * on construction. * * @param array $array * @param bool $allowModifications */ public function __construct(array $array, $allowModifications = false) { $this->allowModifications = (bool) $allowModifications; foreach ($array as $key => $value) { if (is_array($value)) { $this->data[$key] = new static($value, $this->allowModifications); } else { $this->data[$key] = $value; } $this->count++; } } /** * Retrieve a value and return $default if there is no element set. * * @param string $name * @param mixed $default * @return mixed */ public function get($name, $default = null) { if (array_key_exists($name, $this->data)) { return $this->data[$name]; } return $default; } /** * Magic function so that $obj->value will work. * * @param string $name * @return mixed */ public function __get($name) { return $this->get($name); } /** * Set a value in the config. * * Only allow setting of a property if $allowModifications was set to true * on construction. Otherwise, throw an exception. * * @param string $name * @param mixed $value * @return void * @throws Exception\RuntimeException */ public function __set($name, $value) { if ($this->allowModifications) { if (is_array($value)) { $value = new static($value, true); } if (null === $name) { $this->data[] = $value; } else { $this->data[$name] = $value; } $this->count++; } else { throw new Exception\RuntimeException('Config is read only'); } } /** * Deep clone of this instance to ensure that nested Zend\Configs are also * cloned. * * @return void */ public function __clone() { $array = array(); foreach ($this->data as $key => $value) { if ($value instanceof self) { $array[$key] = clone $value; } else { $array[$key] = $value; } } $this->data = $array; } /** * Return an associative array of the stored data. * * @return array */ public function toArray() { $array = array(); $data = $this->data; /** @var self $value */ foreach ($data as $key => $value) { if ($value instanceof self) { $array[$key] = $value->toArray(); } else { $array[$key] = $value; } } return $array; } /** * isset() overloading * * @param string $name * @return bool */ public function __isset($name) { return isset($this->data[$name]); } /** * unset() overloading * * @param string $name * @return void * @throws Exception\InvalidArgumentException */ public function __unset($name) { if (!$this->allowModifications) { throw new Exception\InvalidArgumentException('Config is read only'); } elseif (isset($this->data[$name])) { unset($this->data[$name]); $this->count--; $this->skipNextIteration = true; } } /** * count(): defined by Countable interface. * * @see Countable::count() * @return int */ public function count() { return $this->count; } /** * current(): defined by Iterator interface. * * @see Iterator::current() * @return mixed */ public function current() { $this->skipNextIteration = false; return current($this->data); } /** * key(): defined by Iterator interface. * * @see Iterator::key() * @return mixed */ public function key() { return key($this->data); } /** * next(): defined by Iterator interface. * * @see Iterator::next() * @return void */ public function next() { if ($this->skipNextIteration) { $this->skipNextIteration = false; return; } next($this->data); } /** * rewind(): defined by Iterator interface. * * @see Iterator::rewind() * @return void */ public function rewind() { $this->skipNextIteration = false; reset($this->data); } /** * valid(): defined by Iterator interface. * * @see Iterator::valid() * @return bool */ public function valid() { return ($this->key() !== null); } /** * offsetExists(): defined by ArrayAccess interface. * * @see ArrayAccess::offsetExists() * @param mixed $offset * @return bool */ public function offsetExists($offset) { return $this->__isset($offset); } /** * offsetGet(): defined by ArrayAccess interface. * * @see ArrayAccess::offsetGet() * @param mixed $offset * @return mixed */ public function offsetGet($offset) { return $this->__get($offset); } /** * offsetSet(): defined by ArrayAccess interface. * * @see ArrayAccess::offsetSet() * @param mixed $offset * @param mixed $value * @return void */ public function offsetSet($offset, $value) { $this->__set($offset, $value); } /** * offsetUnset(): defined by ArrayAccess interface. * * @see ArrayAccess::offsetUnset() * @param mixed $offset * @return void */ public function offsetUnset($offset) { $this->__unset($offset); } /** * Merge another Config with this one. * * For duplicate keys, the following will be performed: * - Nested Configs will be recursively merged. * - Items in $merge with INTEGER keys will be appended. * - Items in $merge with STRING keys will overwrite current values. * * @param Config $merge * @return Config */ public function merge(Config $merge) { /** @var Config $value */ foreach ($merge as $key => $value) { if (array_key_exists($key, $this->data)) { if (is_int($key)) { $this->data[] = $value; } elseif ($value instanceof self && $this->data[$key] instanceof self) { $this->data[$key]->merge($value); } else { if ($value instanceof self) { $this->data[$key] = new static($value->toArray(), $this->allowModifications); } else { $this->data[$key] = $value; } } } else { if ($value instanceof self) { $this->data[$key] = new static($value->toArray(), $this->allowModifications); } else { $this->data[$key] = $value; } $this->count++; } } return $this; } /** * Prevent any more modifications being made to this instance. * * Useful after merge() has been used to merge multiple Config objects * into one object which should then not be modified again. * * @return void */ public function setReadOnly() { $this->allowModifications = false; /** @var Config $value */ foreach ($this->data as $value) { if ($value instanceof self) { $value->setReadOnly(); } } } /** * Returns whether this Config object is read only or not. * * @return bool */ public function isReadOnly() { return !$this->allowModifications; } } $obj = new Config( array( 'titulo' => 'CAWZ :: Central Admin Web Zone', 'dominio' => $_SERVER['HTTP_HOST'], 'urlActual' => $_SERVER['REQUEST_URI'], 'pagina' => basename($_SERVER['SCRIPT_NAME']), 'basePath' => dirname($_SERVER['DOCUMENT_ROOT']), 'clases' => dirname(dirname($_SERVER['DOCUMENT_ROOT'])) . '/libs', 'plantillas' => dirname($_SERVER['DOCUMENT_ROOT']) . '/plantillas/', 'traducciones' => dirname(dirname($_SERVER['DOCUMENT_ROOT'])) . '/idiomas', 'imagenes' => array( 'apartamentos' => array( 'path' => dirname($_SERVER['DOCUMENT_ROOT']) . '/www/apartamentos', 'sizes' => array('s' => '120x90', 'm' => '120x90', 'l' => '120x90'), ) ), 'idioma' => array( 'base' => 'es', 'locales' => array('es' => 'es_ES.UTF8', 'en' => 'en_US.UTF8') ), 'debug' => true ) );

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.3.60.0190.00016.75
8.3.50.0130.00621.95
8.3.40.0040.01118.97
8.3.30.0040.01119.13
8.3.20.0040.00420.20
8.3.10.0060.00323.48
8.3.00.0040.00717.63
8.2.180.0220.00018.29
8.2.170.0090.00622.96
8.2.160.0080.00620.65
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0100.00326.16
8.2.120.0080.00022.20
8.2.110.0100.00022.23
8.2.100.0080.00317.91
8.2.90.0000.00819.21
8.2.80.0050.00518.05
8.2.70.0030.00617.63
8.2.60.0030.00518.16
8.2.50.0040.00418.07
8.2.40.0080.00018.30
8.2.30.0030.00618.13
8.2.20.0020.00517.76
8.2.10.0040.00418.20
8.2.00.0060.00317.99
8.1.280.0150.00625.92
8.1.270.0060.00923.91
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0000.01023.84
8.1.230.0110.00019.06
8.1.220.0050.00317.78
8.1.210.0000.00818.77
8.1.200.0030.00617.38
8.1.190.0050.00317.76
8.1.180.0080.00318.10
8.1.170.0050.00318.83
8.1.160.0070.00022.09
8.1.150.0080.00318.65
8.1.140.0040.00417.60
8.1.130.0000.00717.96
8.1.120.0000.00817.57
8.1.110.0040.00417.43
8.1.100.0050.00217.55
8.1.90.0060.00317.55
8.1.80.0060.00317.56
8.1.70.0000.00717.47
8.1.60.0040.00417.57
8.1.50.0030.00517.66
8.1.40.0040.00417.52
8.1.30.0030.00517.77
8.1.20.0000.00817.64
8.1.10.0040.00417.64
8.1.00.0000.01017.48
8.0.300.0030.00519.09
8.0.290.0070.00017.30
8.0.280.0070.00018.53
8.0.270.0040.00417.35
8.0.260.0030.00317.33
8.0.250.0030.00317.03
8.0.240.0000.00717.13
8.0.230.0000.00917.00
8.0.220.0030.00316.91
8.0.210.0040.00417.04
8.0.200.0030.00616.99
8.0.190.0030.00517.09
8.0.180.0040.00416.94
8.0.170.0040.00417.09
8.0.160.0030.00617.00
8.0.150.0050.00316.99
8.0.140.0050.00216.99
8.0.130.0030.00313.41
8.0.120.0010.00615.16
8.0.110.0040.00415.24
8.0.100.0050.00215.28
8.0.90.0040.00415.29
8.0.80.0070.00415.26
8.0.70.0030.00415.19
8.0.60.0050.00315.20
8.0.50.0030.00515.18
8.0.30.0100.00516.02
8.0.20.0060.00916.10
8.0.10.0060.00315.25
8.0.00.0080.00615.85
7.4.330.0020.00215.00
7.4.320.0000.00716.68
7.4.300.0030.00316.68
7.4.290.0070.00016.53
7.4.280.0070.00016.54
7.4.270.0040.00416.54
7.4.260.0070.00016.53
7.4.250.0050.00315.05
7.4.240.0040.00415.52
7.4.230.0030.00514.93
7.4.220.0080.00614.99
7.4.210.0070.00815.84
7.4.200.0040.00415.04
7.4.190.0000.00715.00
7.4.180.0000.00713.44
7.4.160.0050.00915.10
7.4.150.0050.00715.38
7.4.140.0100.00616.34
7.4.130.0050.00915.39
7.4.120.0110.00615.51
7.4.110.0050.00814.99
7.4.100.0050.00915.01
7.4.90.0080.00514.90
7.4.80.0090.00716.40
7.4.70.0080.00515.05
7.4.60.0070.00514.98
7.4.50.0050.00114.84
7.4.40.0080.00518.00
7.4.30.0020.01115.00
7.4.20.0080.00013.18
7.4.10.0060.00714.23
7.4.00.0070.00614.56
7.3.330.0050.00013.38
7.3.320.0000.00513.48
7.3.310.0050.00614.88
7.3.300.0060.00414.99
7.3.290.0100.00415.01
7.3.280.0080.00715.72
7.3.270.0110.00615.38
7.3.260.0110.00515.02
7.3.250.0090.00815.59
7.3.240.0050.00714.88
7.3.230.0050.00714.96
7.3.220.0040.00513.42
7.3.210.0140.00314.94
7.3.200.0110.00516.41
7.3.190.0040.01314.98
7.3.180.0090.00514.87
7.3.170.0070.00514.93
7.3.160.0100.00314.97
7.3.150.0000.00713.29
7.3.140.0000.00613.41
7.3.130.0030.00714.04
7.3.120.0050.00914.33
7.3.110.0060.00614.15
7.3.100.0060.00414.16
7.3.90.0050.00614.33
7.3.80.0020.00614.21
7.3.70.0050.00414.20
7.3.60.0060.00614.26
7.3.50.0030.00714.25
7.3.40.0070.00514.20
7.3.30.0050.00514.15
7.3.20.0040.00515.90
7.3.10.0060.00716.02
7.3.00.0130.00415.98
7.2.340.0120.00013.49
7.2.330.0090.00715.13
7.2.320.0110.00515.09
7.2.310.0080.01015.02
7.2.300.0110.00615.05
7.2.290.0100.00515.21
7.2.280.0080.00413.34
7.2.270.0100.00213.48
7.2.260.0080.00814.20
7.2.250.0050.00914.21
7.2.240.0050.01014.37
7.2.230.0100.00314.39
7.2.220.0070.00714.28
7.2.210.0050.00614.38
7.2.200.0090.00514.23
7.2.190.0100.00614.33
7.2.180.0070.00714.38
7.2.170.0060.00614.52
7.2.160.0080.00614.33
7.2.150.0080.00316.17
7.2.140.0050.00716.08
7.2.130.0110.00816.42
7.2.120.0080.00616.33
7.2.110.0130.00616.20
7.2.100.0100.00316.32
7.2.90.0160.00316.37
7.2.80.0180.00716.47
7.2.70.0150.00616.41
7.2.60.0140.00616.47
7.2.50.0060.01016.28
7.2.40.0200.00516.24
7.2.30.0120.00816.34
7.2.20.0160.00616.47
7.2.10.0090.00916.43
7.2.00.0140.00916.44
7.1.330.0050.00715.05
7.1.320.0090.00415.21
7.1.310.0110.00214.96
7.1.300.0070.00615.01
7.1.290.0090.00415.02
7.1.280.0110.00314.94
7.1.270.0090.00515.21
7.1.260.0060.00615.17
7.1.250.0110.00615.30
7.1.240.0100.00215.10
7.1.230.0060.00415.14
7.1.220.0090.00415.04
7.1.210.0080.00215.04
7.1.200.0080.00415.14
7.1.190.0100.00515.06
7.1.180.0120.00315.00
7.1.170.0030.00815.16
7.1.160.0080.00415.09
7.1.150.0040.00915.00
7.1.140.0050.00814.96
7.1.130.0060.00714.91
7.1.120.0030.00714.86
7.1.110.0060.00615.04
7.1.100.0030.00915.05
7.1.90.0040.00915.17
7.1.80.0060.00515.19
7.1.70.0080.00415.82
7.1.60.0070.00816.54
7.1.50.0060.00815.70
7.1.40.0030.01114.99
7.1.30.0070.00715.12
7.1.20.0050.00714.95
7.1.10.0030.01014.88
7.1.00.0030.03217.54
7.0.330.0070.00314.83
7.0.320.0080.00314.84
7.0.310.0050.00814.71
7.0.300.0070.00714.81
7.0.290.0040.00714.73
7.0.280.0050.00514.75
7.0.270.0100.00114.85
7.0.260.0060.00614.88
7.0.250.0060.00614.81
7.0.240.0060.00814.85
7.0.230.0040.00914.79
7.0.220.0060.00514.74
7.0.210.0090.00514.89
7.0.200.0100.00315.53
7.0.190.0080.00614.88
7.0.180.0090.00314.89
7.0.170.0050.01014.91
7.0.160.0040.00914.74
7.0.150.0100.00314.85
7.0.140.0080.02917.14
7.0.130.0070.00514.81
7.0.120.0070.00314.83
7.0.110.0080.00614.87
7.0.100.0120.02716.59
7.0.90.0100.02716.43
7.0.80.0050.03416.53
7.0.70.0050.02316.62
7.0.60.0090.01716.53
7.0.50.0030.03316.64
7.0.40.0070.03016.06
7.0.30.0100.02915.90
7.0.20.0100.02715.91
7.0.10.0120.02815.88
7.0.00.0110.02515.92
5.6.400.0100.00313.84
5.6.390.0060.00713.72
5.6.380.0090.00413.73
5.6.370.0080.00513.77
5.6.360.0110.00413.80
5.6.350.0060.00813.80
5.6.340.0080.00313.60
5.6.330.0090.00613.61
5.6.320.0100.00413.87
5.6.310.0070.00613.71
5.6.300.0060.01013.65
5.6.290.0110.00013.71
5.6.280.0080.02516.27
5.6.270.0090.00413.65
5.6.260.0100.00313.58
5.6.250.0070.03116.00
5.6.240.0090.01816.02
5.6.230.0100.02916.17
5.6.220.0050.03316.10
5.6.210.0090.02816.17
5.6.200.0070.01816.28
5.6.190.0070.03416.14
5.6.180.0040.03416.22
5.6.170.0090.02816.09
5.6.160.0090.02916.21
5.6.150.0090.02816.19
5.6.140.0090.02916.21
5.6.130.0100.02816.23
5.6.120.0100.03016.09
5.6.110.0120.02816.11
5.6.100.0100.03116.19
5.6.90.0090.02916.13
5.6.80.0060.03115.94
5.6.70.0070.02616.03
5.6.60.0130.02216.00
5.6.50.0040.02916.04
5.6.40.0070.02815.95
5.6.30.0080.03015.86
5.6.20.0080.02815.92
5.6.10.0050.03115.95
5.6.00.0060.03115.90
5.5.380.0060.03016.11
5.5.370.0030.03216.11
5.5.360.0050.03615.91
5.5.350.0050.03215.97
5.5.340.0090.02616.27
5.5.330.0080.02016.08
5.5.320.0040.03115.91
5.5.310.0090.03116.06
5.5.300.0090.03216.15
5.5.290.0040.03516.09
5.5.280.0090.02916.11
5.5.270.0030.03616.09
5.5.260.0080.02416.04
5.5.250.0090.03016.00
5.5.240.0070.03015.97
5.5.230.0050.02915.96
5.5.220.0100.02815.99
5.5.210.0060.03415.92
5.5.200.0110.02715.86
5.5.190.0070.02915.84
5.5.180.0080.01915.82
5.5.170.0060.00413.85
5.5.160.0070.02815.81
5.5.150.0060.03215.67
5.5.140.0050.02515.79
5.5.130.0090.02715.74
5.5.120.0070.03115.74
5.5.110.0060.02715.83
5.5.100.0110.02715.64
5.5.90.0100.02615.87
5.5.80.0070.02915.77
5.5.70.0120.02215.82
5.5.60.0060.03115.94
5.5.50.0070.02915.90
5.5.40.0100.02615.86
5.5.30.0090.02615.94
5.5.20.0060.02715.87
5.5.10.0030.02315.70
5.5.00.0080.03015.78
5.4.450.0050.02215.03
5.4.440.0090.02715.16
5.4.430.0080.02115.01
5.4.420.0090.02615.09
5.4.410.0060.02715.00
5.4.400.0110.02515.02
5.4.390.0060.02714.94
5.4.380.0070.03014.97
5.4.370.0080.02615.04
5.4.360.0060.03114.99
5.4.350.0080.02614.97
5.4.340.0080.02914.85
5.4.330.0070.00412.83
5.4.320.0070.02615.00
5.4.310.0050.03014.88
5.4.300.0060.02615.01
5.4.290.0070.02814.92
5.4.280.0100.02614.98
5.4.270.0070.02615.04
5.4.260.0060.02614.89
5.4.250.0050.02614.91
5.4.240.0080.02614.97
5.4.230.0090.02614.80
5.4.220.0070.02314.91
5.4.210.0040.03214.90
5.4.200.0120.02214.88
5.4.190.0030.03214.77
5.4.180.0060.02914.95
5.4.170.0060.01914.81
5.4.160.0050.02814.82
5.4.150.0050.02914.96
5.4.140.0060.02814.06
5.4.130.0050.02914.04
5.4.120.0070.02714.12
5.4.110.0090.01714.07
5.4.100.0060.02814.12
5.4.90.0100.02614.14
5.4.80.0080.02614.06
5.4.70.0090.02614.05
5.4.60.0110.01214.14
5.4.50.0070.02614.09
5.4.40.0070.02714.17
5.4.30.0060.02714.11
5.4.20.0050.02814.06
5.4.10.0070.02814.15
5.4.00.0110.02313.86
5.3.290.0060.02613.60
5.3.280.0070.02913.58
5.3.270.0070.02813.68
5.3.260.0050.02413.57
5.3.250.0050.02613.57
5.3.240.0060.02813.53
5.3.230.0070.02913.61
5.3.220.0070.02913.55
5.3.210.0090.02713.61
5.3.200.0060.02813.52
5.3.190.0080.02813.55
5.3.180.0080.02713.61
5.3.170.0050.02813.69
5.3.160.0140.02213.68
5.3.150.0070.02613.66
5.3.140.0020.02013.63
5.3.130.0060.01813.57
5.3.120.0110.02713.58
5.3.110.0100.02413.63
5.3.100.0090.02313.44
5.3.90.0090.02713.47
5.3.80.0060.02713.39
5.3.70.0020.03013.43
5.3.60.0060.02613.42
5.3.50.0070.02113.34
5.3.40.0070.02313.45
5.3.30.0090.02213.39
5.3.20.0060.02213.31
5.3.10.0080.02113.19
5.3.00.0040.02413.21

preferences:
49.33 ms | 400 KiB | 5 Q