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 => $column) { 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.0110.01118.43
8.3.50.0110.00718.15
8.3.40.0100.01018.88
8.3.30.0110.00718.85
8.3.20.0000.00820.25
8.3.10.0070.00023.57
8.3.00.0080.00319.57
8.2.180.0090.00618.48
8.2.170.0110.00722.96
8.2.160.0000.01420.44
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0050.00221.18
8.2.110.0050.00520.52
8.2.100.0080.00417.84
8.2.90.0050.00318.03
8.2.80.0040.00419.45
8.2.70.0030.00517.93
8.2.60.0050.00318.04
8.2.50.0040.00418.22
8.2.40.0050.00320.47
8.2.30.0070.00019.33
8.2.20.0030.00618.15
8.2.10.0000.00818.14
8.2.00.0040.00418.29
8.1.280.0070.01425.92
8.1.270.0080.00022.05
8.1.260.0060.00326.35
8.1.250.0000.00728.09
8.1.240.0100.00022.46
8.1.230.0110.00021.03
8.1.220.0040.00417.78
8.1.210.0040.00418.77
8.1.200.0030.00617.36
8.1.190.0030.00617.35
8.1.180.0050.00318.10
8.1.170.0040.00418.59
8.1.160.0070.00018.93
8.1.150.0000.00720.30
8.1.140.0050.00217.70
8.1.130.0060.00319.07
8.1.120.0080.00017.58
8.1.110.0020.00517.53
8.1.100.0000.00717.35
8.1.90.0040.00417.46
8.1.80.0000.00817.53
8.1.70.0030.00317.50
8.1.60.0000.00717.54
8.1.50.0040.00417.52
8.1.40.0000.00817.42
8.1.30.0080.00017.75
8.1.20.0040.00417.72
8.1.10.0040.00417.54
8.1.00.0060.00317.52
8.0.300.0080.00021.95
8.0.290.0040.00416.75
8.0.280.0040.00418.57
8.0.270.0070.00017.34
8.0.260.0000.00716.93
8.0.250.0000.00717.07
8.0.240.0030.00317.06
8.0.230.0070.00017.07
8.0.220.0030.00316.88
8.0.210.0030.00317.02
8.0.200.0000.00716.96
8.0.190.0080.00317.09
8.0.180.0020.00516.91
8.0.170.0000.00816.91
8.0.160.0040.00416.95
8.0.150.0000.00816.89
8.0.140.0030.00616.95
8.0.130.0000.00613.40
8.0.120.0030.00516.91
8.0.110.0000.00816.99
8.0.100.0040.00416.96
8.0.90.0050.00216.84
8.0.80.0060.01517.06
8.0.70.0040.00416.93
8.0.60.0000.00817.03
8.0.50.0070.00016.83
8.0.30.0110.00917.17
8.0.20.0130.00817.42
8.0.10.0050.00217.23
8.0.00.0070.01216.79
7.4.330.0050.00015.55
7.4.320.0030.00316.68
7.4.300.0030.00316.63
7.4.290.0030.00316.61
7.4.280.0000.00716.52
7.4.270.0070.00016.65
7.4.260.0070.00016.46
7.4.250.0070.00016.61
7.4.240.0050.00316.59
7.4.230.0000.00716.39
7.4.220.0040.00416.38
7.4.210.0020.01416.54
7.4.200.0030.00316.64
7.4.160.0110.00516.54
7.4.150.0050.01417.40
7.4.140.0060.01117.86
7.4.130.0080.00816.72
7.4.120.0110.00816.57
7.4.110.0090.00816.43
7.4.100.0110.00516.45
7.4.90.0210.00316.59
7.4.80.0100.01419.39
7.4.70.0090.01216.61
7.4.60.0060.01016.48
7.4.50.0050.00616.49
7.4.40.0110.00616.59
7.4.00.0060.00614.88
7.3.330.0050.00013.30
7.3.320.0000.00513.22
7.3.310.0040.00416.35
7.3.300.0000.00716.30
7.3.290.0060.00916.40
7.3.280.0070.00816.44
7.3.270.0100.01017.40
7.3.260.0130.00716.50
7.3.240.0050.01416.48
7.3.230.0090.00916.46
7.3.210.0100.00716.45
7.3.200.0170.00316.50
7.3.190.0070.01016.43
7.3.180.0030.01316.51
7.3.170.0060.00916.45
7.3.160.0120.00316.45
7.2.330.0090.00916.45
7.2.320.0030.01516.81
7.2.310.0110.00616.52
7.2.300.0100.01416.67
7.2.290.0050.01316.68
7.2.110.0250.00016.82
7.2.60.0070.00416.74
7.2.20.0130.00718.01
7.2.10.0070.01517.48
7.2.00.0460.01917.89
7.1.200.0070.00715.63
7.1.140.0350.01016.42
7.1.130.0120.00516.88
7.1.120.0110.00716.53
7.1.110.0260.01616.17
7.1.100.0670.01316.21
7.1.90.0100.01015.65
7.1.80.0080.00915.82
7.1.70.0020.01315.33
7.1.60.0190.01833.38
7.1.50.0520.01833.16
7.1.40.0510.01032.61
7.1.30.0640.00632.93
7.1.20.0590.01632.70
7.1.10.0480.01114.73
7.1.00.0720.01314.91

preferences:
39.9 ms | 400 KiB | 5 Q