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; $foo->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.60.0040.01118.43
8.3.50.0090.00616.47
8.3.40.0080.00818.72
8.3.30.0040.01118.77
8.3.20.0040.00420.34
8.3.10.0040.00421.74
8.3.00.0040.00421.90
8.2.180.0070.00718.30
8.2.170.0090.00622.96
8.2.160.0080.00620.52
8.2.150.0030.00524.18
8.2.140.0090.00024.66
8.2.130.0060.00320.80
8.2.120.0080.00026.35
8.2.110.0060.00319.27
8.2.100.0000.01217.80
8.2.90.0080.00018.92
8.2.80.0000.00817.97
8.2.70.0080.00017.38
8.2.60.0060.00317.92
8.2.50.0040.00418.09
8.2.40.0040.00420.61
8.2.30.0080.00019.33
8.2.20.0050.00217.59
8.2.10.0040.00418.00
8.2.00.0000.00717.84
8.1.280.0110.00725.92
8.1.270.0100.00722.19
8.1.260.0040.00428.09
8.1.250.0050.00328.09
8.1.240.0090.00021.02
8.1.230.0040.00817.67
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0080.00017.23
8.1.190.0060.00317.23
8.1.180.0050.00318.10
8.1.170.0050.00318.61
8.1.160.0030.00720.77
8.1.150.0040.00420.65
8.1.140.0030.00619.40
8.1.130.0000.00717.56
8.1.120.0050.00217.36
8.1.110.0000.00817.35
8.1.100.0050.00217.38
8.1.90.0040.00417.41
8.1.80.0040.00417.26
8.1.70.0030.00317.36
8.1.60.0060.00317.47
8.1.50.0030.00617.40
8.1.40.0080.00017.39
8.1.30.0050.00317.61
8.1.20.0030.00617.45
8.1.10.0040.00417.40
8.1.00.0030.00517.36
8.0.300.0080.00018.96
8.0.290.0000.00716.63
8.0.280.0000.00718.31
8.0.270.0000.00717.10
8.0.260.0000.00617.15
8.0.250.0000.00716.89
8.0.240.0060.00016.93
8.0.230.0000.00716.90
8.0.220.0050.00316.91
8.0.210.0000.00716.83
8.0.200.0030.00316.94
8.0.190.0000.00816.93
8.0.180.0070.00016.89
8.0.170.0000.00716.88
8.0.160.0000.00816.79
8.0.150.0050.00216.71
8.0.140.0000.00716.85
8.0.130.0050.00013.33
8.0.120.0040.00416.88
8.0.110.0040.00416.87
8.0.100.0030.00516.86
8.0.90.0000.00716.73
8.0.80.0070.01016.80
8.0.70.0050.00216.97
8.0.60.0050.00316.86
8.0.50.0040.00416.92
8.0.30.0130.00416.91
8.0.20.0100.00817.40
8.0.10.0080.00016.94
8.0.00.0110.00716.61
7.4.330.0030.00316.67
7.4.320.0000.00616.56
7.4.300.0080.00016.61
7.4.290.0030.00316.48
7.4.280.0060.00316.54
7.4.270.0040.00416.47
7.4.260.0000.00716.55
7.4.250.0030.00316.42
7.4.240.0030.00316.50
7.4.230.0000.00716.59
7.4.220.0000.01916.59
7.4.210.0100.00716.49
7.4.200.0030.00316.50
7.4.160.0090.00916.49
7.4.150.0120.00617.40
7.4.140.0100.01117.86
7.4.130.0050.01116.56
7.4.120.0060.01116.51
7.4.110.0110.00616.40
7.4.100.0150.00316.63
7.4.90.0130.00416.61
7.4.80.0130.01019.39
7.4.70.0120.00416.54
7.4.60.0150.00316.58
7.4.50.0040.01116.68
7.4.40.0070.01016.59
7.4.30.0130.01116.54
7.4.00.0110.00715.20
7.3.330.0030.00313.34
7.3.320.0050.00013.22
7.3.310.0030.00316.49
7.3.300.0040.00416.24
7.3.290.0070.00016.43
7.3.280.0090.01216.40
7.3.270.0040.01317.40
7.3.260.0170.00716.36
7.3.250.0070.01116.40
7.3.240.0090.01016.37
7.3.230.0100.00716.47
7.3.210.0110.00616.61
7.3.200.0090.00619.39
7.3.190.0070.01116.58
7.3.180.0080.00816.43
7.3.170.0060.01116.38
7.3.160.0070.01316.54
7.3.10.0030.01016.68
7.3.00.0090.00316.46
7.2.330.0070.01116.59
7.2.320.0030.01716.54
7.2.310.0030.01416.26
7.2.300.0140.00316.48
7.2.290.0070.01016.21
7.2.130.0080.00316.95
7.2.120.0110.00416.78
7.2.110.0030.01316.72
7.2.100.0000.01416.72
7.2.90.0110.00016.81
7.2.80.0060.00616.67
7.2.70.0040.00716.73
7.2.60.0100.00316.60
7.2.50.0070.00316.82
7.2.40.0040.00716.89
7.2.30.0070.00716.68
7.2.20.0060.00616.82
7.2.10.0060.00316.97
7.2.00.0020.01217.87
7.1.250.0110.00415.57
7.1.200.0060.00615.65
7.1.100.0000.00918.07
7.1.70.0030.00617.10
7.1.60.0030.02219.40
7.1.50.0130.00016.73
7.1.00.0000.07722.41
7.0.200.0230.00014.74
7.0.60.0230.06021.66
7.0.50.0130.07017.92
7.0.40.0170.07720.02
7.0.30.0270.04320.25
7.0.20.0370.04720.16
7.0.10.0030.05720.08
7.0.00.0100.08020.15
5.6.280.0070.05721.14
5.6.210.0070.08020.64
5.6.200.0070.06018.20
5.6.190.0100.06720.60
5.6.180.0270.08020.47
5.6.170.0270.07720.55
5.6.160.0100.05020.39
5.6.150.0070.03718.16
5.6.140.0030.04318.16
5.6.130.0100.07718.24
5.6.120.0070.06721.13
5.6.110.0100.08321.02
5.6.100.0070.08321.13
5.6.90.0070.08321.01
5.6.80.0170.07020.55
5.5.350.0200.07720.51
5.5.340.0030.08317.93
5.5.330.0030.04320.19
5.5.320.0600.06020.40
5.5.310.0200.06020.33
5.5.300.0130.05318.04
5.5.290.0030.08317.95
5.5.280.0170.07320.79
5.5.270.0070.05020.66
5.5.260.0070.07020.88
5.5.250.0170.07320.60
5.5.240.3900.03720.17

preferences:
70.31 ms | 401 KiB | 5 Q