3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Immutable { private $_defaultValues = []; private $_userDefinedValues = []; private $_userDefinedProperties = []; private static $_doNotTakeOverProperties = [ '_defaultValues' => true, '_userDefinedValues' => true, '_userDefinedProperties' => true, ]; final public function __construct() { var_dump("in trait constructor"); // take over all user-defined non-static properties foreach ((new \ReflectionObject($this))->getProperties() as $property) { $propertyName = $property->getName(); if (isset(self::$_doNotTakeOverProperties[$propertyName]) || $property->isStatic()) { continue; } $this->_userDefinedProperties[$propertyName] = true; $this->_defaultValues[$propertyName] = $property->getValue($this); unset($this->{$property->getName()}); } } final public function __set($name, $value) { if (!isset($this->_userDefinedProperties[$name])) { throw new \LogicException('Unknown property "' . $name . '"'); } if (array_key_exists($name, $this->_userDefinedValues)) { throw new \LogicException('You can not overwrite the value for property "' . $name . '"'); } $this->_userDefinedValues[$name] = $value; } final public function __get($name) { if (!isset($this->_userDefinedProperties[$name])) { throw new \LogicException('Unknown property "' . $name . '"'); } if (array_key_exists($name, $this->_userDefinedValues)) { return $this->_userDefinedValues[$name]; } return $this->_defaultValues[$name]; } } class Foo { use Immutable; public $poo; public function __construct() { var_dump("in class constructor"); parent::__construct(); } } $foo = new Foo; $foo->poo = 1; $bar = new Foo; $bar->poo = 2;

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.40.0070.00718.68
8.3.30.0110.00418.72
8.3.20.0040.00420.35
8.3.10.0040.00421.90
8.3.00.0000.01123.66
8.2.170.0150.00422.96
8.2.160.0030.01020.34
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0000.00820.69
8.2.120.0080.00026.35
8.2.110.0060.00320.46
8.2.100.0090.00317.83
8.2.90.0000.00817.75
8.2.80.0050.00517.97
8.2.70.0080.00017.92
8.2.60.0000.00817.97
8.2.50.0040.00418.10
8.2.40.0000.00719.22
8.2.30.0040.00417.85
8.2.20.0000.00817.47
8.2.10.0000.00718.03
8.2.00.0000.00717.98
8.1.270.0180.00022.19
8.1.260.0050.00228.09
8.1.250.0080.00028.09
8.1.240.0120.00023.79
8.1.230.0080.00321.00
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0060.00616.85
8.1.190.0080.00017.10
8.1.180.0070.00018.10
8.1.170.0030.00618.46
8.1.160.0020.00518.75
8.1.150.0040.00418.98
8.1.140.0030.00619.36
8.1.130.0030.00317.52
8.1.120.0040.00417.43
8.1.110.0040.00317.26
8.1.100.0000.00717.27
8.1.90.0040.00417.38
8.1.80.0080.00017.27
8.1.70.0000.00717.43
8.1.60.0040.00417.48
8.1.50.0040.00417.42
8.1.40.0030.00517.38
8.1.30.0030.00617.49
8.1.20.0030.00617.57
8.1.10.0000.00817.39
8.1.00.0000.00817.36
8.0.300.0000.00819.64
8.0.290.0040.00416.63
8.0.280.0000.00718.39
8.0.270.0000.00717.12
8.0.260.0070.00017.20
8.0.250.0030.00316.95
8.0.240.0070.00016.79
8.0.230.0000.00716.89
8.0.220.0000.01016.90
8.0.210.0060.00316.84
8.0.200.0060.00016.96
8.0.190.0030.00516.81
8.0.180.0000.00816.78
8.0.170.0070.00016.79
8.0.160.0000.00816.95
8.0.150.0070.00016.65
8.0.140.0000.00816.70
8.0.130.0000.00513.21
8.0.120.0060.00316.74
8.0.110.0050.00216.84
8.0.100.0070.00016.65
8.0.90.0000.00716.73
8.0.80.0070.01116.79
8.0.70.0050.00216.71
8.0.60.0040.00416.81
8.0.50.0000.00716.74
8.0.30.0110.00616.80
8.0.20.0060.01217.40
8.0.10.0040.00416.79
8.0.00.0110.00916.63
7.4.330.0060.00016.66
7.4.320.0060.00016.61
7.4.300.0050.00316.58
7.4.290.0000.00816.39
7.4.280.0000.00816.57
7.4.270.0040.00316.50
7.4.260.0040.00416.45
7.4.250.0000.00716.42
7.4.240.0030.00316.38
7.4.230.0020.00516.53
7.4.220.0070.01116.66
7.4.210.0110.00616.47
7.4.200.0000.00816.45
7.4.160.0080.00816.51
7.4.150.0000.01917.40
7.4.140.0140.00817.86
7.4.130.0080.01116.43
7.4.120.0090.00816.48
7.4.110.0180.00016.52
7.4.100.0000.01716.70
7.4.90.0070.01116.55
7.4.80.0070.01119.39
7.4.70.0140.00316.48
7.4.60.0030.01716.66
7.4.50.0070.01116.30
7.4.40.0100.00616.37
7.4.30.0130.01016.62
7.4.00.0090.01014.94
7.3.330.0030.00313.42
7.3.320.0050.00013.43
7.3.310.0030.00416.43
7.3.300.0040.00416.26
7.3.290.0000.00716.31
7.3.280.0070.01016.37
7.3.270.0090.00917.40
7.3.260.0100.01016.57
7.3.250.0090.00816.55
7.3.240.0090.00916.50
7.3.230.0070.01416.39
7.3.210.0060.00916.47
7.3.200.0070.00719.39
7.3.190.0090.00916.41
7.3.180.0030.01416.53
7.3.170.0080.00816.49
7.3.160.0090.00916.47
7.3.120.0090.00914.90
7.3.110.0100.01014.98
7.3.100.0090.00414.54
7.3.90.0070.00715.10
7.3.80.0000.01614.89
7.3.70.0140.00314.85
7.3.60.0140.00314.89
7.3.50.0070.01014.90
7.3.40.0130.00314.71
7.3.30.0070.01014.73
7.3.20.0030.01016.73
7.3.10.0110.00616.46
7.3.00.0100.00916.63
7.2.330.0140.00316.53
7.2.320.0130.01316.61
7.2.310.0100.00616.71
7.2.300.0040.01316.38
7.2.290.0070.01016.55
7.2.250.0070.01015.01
7.2.240.0100.01014.87
7.2.230.0040.01014.52
7.2.220.0060.01014.56
7.2.210.0070.00714.96
7.2.200.0070.01014.64
7.2.190.0090.00614.93
7.2.180.0060.00315.15
7.2.170.0100.00714.59
7.2.130.0070.01116.47
7.2.120.0090.00616.53
7.2.110.0160.00016.28
7.2.100.0100.00716.69
7.2.90.0090.00616.75
7.2.80.0090.01216.75
7.2.70.0090.00316.80
7.2.60.0070.00616.68
7.2.50.0120.00616.91
7.2.40.0130.00816.39
7.2.30.0150.00616.81
7.2.20.0110.00716.55
7.2.10.0140.00716.29
7.2.00.0070.00917.83
7.1.330.0140.00015.50
7.1.320.0120.00315.64
7.1.310.0060.00915.61
7.1.300.0000.01515.73
7.1.290.0000.01315.39
7.1.280.0000.01015.36
7.1.270.0100.00715.54
7.1.260.0030.01015.71
7.1.250.0210.00715.65
7.1.200.0080.00415.63
7.1.100.0000.01117.89
7.1.70.0070.00717.13
7.1.60.0120.01219.40
7.1.50.0090.00616.92
7.1.00.0030.07722.30
7.0.200.0360.00414.90
7.0.60.0300.06721.71
7.0.50.0130.07717.97
7.0.40.0130.08320.05
7.0.30.0270.05720.09
7.0.20.0400.07320.19
7.0.10.0100.04020.14
7.0.00.0030.06320.20
5.6.280.0000.03321.13
5.6.210.0000.07320.49
5.6.200.0030.07018.14
5.6.190.0130.08020.61
5.6.180.0370.07020.57
5.6.170.0300.07320.42
5.6.160.0130.04020.48
5.6.150.0030.04018.28
5.6.140.0100.07018.18
5.6.130.0130.07718.21
5.6.120.0070.04720.98
5.6.110.0130.07321.05
5.6.100.0030.05021.15
5.6.90.0100.07020.99
5.6.80.0000.09020.43
5.5.350.0170.07720.50
5.5.340.0100.03318.02
5.5.330.0130.07720.40
5.5.320.0470.05320.35
5.5.310.0370.07320.37
5.5.300.0100.03317.96
5.5.290.0100.04717.95
5.5.280.0100.05320.89
5.5.270.0030.05020.66
5.5.260.0070.06320.88
5.5.250.0030.06720.70
5.5.240.4230.04320.20

preferences:
56.05 ms | 400 KiB | 5 Q