3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = [ 'legendaryName' => [ 'column' => 'legendary_name', 'type' => 'string', ] ]; $data = ['legendary_name' => 'The Hammer']; class Warrior { use DbHydrate; private $legendaryName; } trait DbHydrate { public function extract($config) { $row = []; foreach($config as $attributeName => $attributeConfig) { if(property_exists($this, $attributeName)) { $columnName = $attributeConfig['column']; $row[$columnName] = $this->{$attributeName}; } else { throw new \Exception(sprintf('The property %s does not exists in %s', $attributeName, self::class)); } } return $row; } public function hydrate($config, $data) { foreach($config as $attributeName => $attributeConfig) { if(property_exists($this, $attributeName)) { $columnName = $attributeConfig['column']; $value = $data[$columnName]; if ($attributeConfig['type'] === 'string' && is_string($value)) { $this->{$attributeName} = $value; } } else { throw new \Exception(sprintf('The property %s does not exists in %s', $attributeName, self::class)); } } } } $legendaryWarrior = new Warrior; $legendaryWarrior->hydrate($config, $data); var_dump($legendaryWarrior->extract($config)); var_dump($legendaryWarrior); /* $config = ['classicalName' => 'classical_name']; $data = ['classical_name' => 'John']; $testWarrior = new Warrior; $testWarrior->hydrate($config, $data); var_dump($testWarrior);*/

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.0210.00018.11
8.3.50.0100.00717.86
8.3.40.0070.00718.67
8.3.30.0070.00718.85
8.3.20.0040.00420.30
8.3.10.0000.00823.48
8.3.00.0060.00618.05
8.2.180.0110.00418.14
8.2.170.0140.00322.96
8.2.160.0060.00920.38
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0050.00321.13
8.2.110.0030.00621.00
8.2.100.0080.00419.45
8.2.90.0050.00317.88
8.2.80.0000.00818.86
8.2.70.0040.00417.75
8.2.60.0000.00817.75
8.2.50.0030.00517.93
8.2.40.0040.00419.65
8.2.30.0040.00419.36
8.2.20.0040.00418.20
8.2.10.0040.00418.04
8.2.00.0040.00418.34
8.1.280.0070.01425.92
8.1.270.0080.00022.18
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.18
8.1.230.0040.00722.75
8.1.220.0040.00418.61
8.1.210.0040.00418.77
8.1.200.0000.00917.65
8.1.190.0040.00417.48
8.1.180.0000.00818.10
8.1.170.0090.00017.62
8.1.160.0040.00418.85
8.1.150.0000.00720.17
8.1.140.0020.00517.80
8.1.130.0040.00417.40
8.1.120.0040.00417.42
8.1.110.0040.00417.43
8.1.100.0080.00017.50
8.1.90.0000.00717.41
8.1.80.0070.00317.50
8.1.70.0040.00417.36
8.1.60.0040.00417.62
8.1.50.0050.00317.40
8.1.40.0000.00817.54
8.1.30.0030.00517.59
8.1.20.0070.00017.59
8.1.10.0060.00317.50
8.1.00.0000.00817.58
8.0.300.0080.00018.77
8.0.290.0050.00216.63
8.0.280.0040.00418.37
8.0.270.0030.00517.32
8.0.260.0030.00316.92
8.0.250.0030.00516.98
8.0.240.0030.00316.87
8.0.230.0070.00017.02
8.0.220.0040.00416.90
8.0.210.0050.00217.02
8.0.200.0070.00017.04
8.0.190.0070.00317.06
8.0.180.0060.00316.91
8.0.170.0000.00816.83
8.0.160.0000.00816.96
8.0.150.0040.00416.91
8.0.140.0000.00716.88
8.0.130.0060.00013.40
8.0.120.0040.00416.95
8.0.110.0050.00316.93
8.0.100.0000.00816.80
8.0.90.0000.00816.88
8.0.80.0070.01416.86
8.0.70.0000.00916.81
8.0.60.0070.00016.98
8.0.50.0040.00416.96
8.0.30.0090.00917.20
8.0.20.0110.00917.41
8.0.10.0040.00416.95
8.0.00.0100.01316.85
7.4.330.0060.00015.55
7.4.320.0000.00616.59
7.4.300.0000.00616.57
7.4.290.0070.00016.47
7.4.280.0020.00516.55
7.4.270.0080.00016.54
7.4.260.0080.00016.63
7.4.250.0030.00316.61
7.4.240.0000.00716.58
7.4.230.0000.00716.66
7.4.220.0000.00816.62
7.4.210.0080.00616.62
7.4.200.0070.00016.53
7.4.160.0070.00916.60
7.4.150.0120.01217.40
7.4.140.0120.00817.86
7.4.130.0040.01516.46
7.4.120.0090.00916.57
7.4.110.0160.00316.46
7.4.100.0090.01216.58
7.4.90.0150.00816.60
7.4.80.0060.01519.39
7.4.70.0220.00016.65
7.4.60.0100.00716.54
7.4.50.0100.00616.50
7.4.40.0030.01416.67
7.4.00.0100.00714.89
7.3.330.0050.00013.26
7.3.320.0030.00313.34
7.3.310.0040.00416.23
7.3.300.0000.00716.27
7.3.290.0030.01116.30
7.3.280.0090.00616.38
7.3.270.0060.01217.40
7.3.260.0160.00616.45
7.3.240.0080.00916.50
7.3.230.0030.01216.42
7.3.210.0140.00316.57
7.3.200.0000.01516.59
7.3.190.0040.01116.29
7.3.180.0120.00916.37
7.3.170.0090.00616.48
7.3.160.0060.00916.64
7.3.120.0060.00915.17
7.3.110.0120.00314.79
7.3.100.0070.01114.89
7.3.90.0060.00914.90
7.3.80.0070.01014.93
7.3.70.0070.00314.85
7.3.60.0070.00714.96
7.3.50.0030.00914.58
7.3.40.0070.00714.68
7.3.30.0100.00614.44
7.3.20.0090.00316.83
7.3.10.0060.00616.61
7.3.00.0030.01216.66
7.2.330.0090.00916.47
7.2.320.0060.01216.61
7.2.310.0170.00016.70
7.2.300.0150.00616.60
7.2.290.0070.01016.44
7.2.240.0070.00714.98
7.2.230.0030.01015.07
7.2.220.0070.01114.99
7.2.210.0030.01315.11
7.2.200.0070.01015.16
7.2.190.0040.01115.12
7.2.180.0090.00615.25
7.2.170.0100.00715.10
7.2.160.0100.00714.99
7.2.150.0060.00916.71
7.2.140.0090.00616.72
7.2.130.0000.01316.95
7.2.120.0030.00716.94
7.2.110.0030.00916.69
7.2.100.0100.00716.87
7.2.90.0060.01016.72
7.2.80.0060.00616.92
7.2.70.0090.00917.00
7.2.60.0050.01217.08
7.2.50.0030.01216.90
7.2.40.0070.01016.84
7.2.30.0070.01016.97
7.2.20.0220.00617.39
7.2.10.0280.00717.52
7.2.00.0220.01117.41
7.1.330.0090.00915.55
7.1.320.0060.00615.54
7.1.310.0030.00715.93
7.1.300.0000.01215.63
7.1.290.0030.00915.78
7.1.280.0070.00715.84
7.1.270.0040.01115.92
7.1.260.0060.00915.92
7.1.250.0040.01215.90
7.1.200.0070.00415.54
7.1.140.0330.00716.61
7.1.130.0370.00716.75
7.1.120.0440.01416.51
7.1.110.0430.00416.24
7.1.100.0450.01616.15
7.1.90.1150.01415.87
7.1.80.0670.01715.73
7.1.70.0800.00315.32
7.1.60.0890.01033.42
7.1.50.0720.02032.99
7.1.40.0730.02032.41
7.1.30.1010.01432.59
7.1.20.0720.01832.74
7.1.10.0690.00915.01
7.1.00.0550.01314.76

preferences:
49.1 ms | 400 KiB | 5 Q