3v4l.org

run code in 300+ PHP versions simultaneously
<?php try { $user = User_DTO::fromApiArray([ 'id' => 1, 'name' => 'Foo', 'username' => 'foo', 'email' => '', 'address' => [ 'street' => '', 'suite' => '', 'city' => '', 'zipcode' => '', 'geo' => [ 'lat' => '', 'lng' => '', ], ], 'phone' => '', 'website' => '', 'company' => [ 'name' => '', 'catchPhrase' => '', 'bs' => '', ], ]); echo $user->get_id() . PHP_EOL; echo $user->get_name() . PHP_EOL; echo $user->get_username() . PHP_EOL; } catch(Exception $e) { echo $e->getMessage(); } class User_DTO { private int $id; private string $name; private string $username; // force use of named constructors private function __construct() { } public static function fromApiArray($array): static { $inst = new static; $inst->id = (int) $array['id']; $inst->name = (string) $array['name']; $inst->username = (string) $array['username']; return $inst; } public function get_id(): int { return $this->id; } public function get_name(): string { return $this->name; } public function get_username(): string { return $this->username; } // etc }

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.00318.30
8.3.50.0040.01116.32
8.3.40.0070.00718.93
8.3.30.0060.00918.67
8.3.20.0050.00224.18
8.3.10.0050.00224.66
8.3.00.0040.00426.16
8.2.180.0150.00325.92
8.2.170.0130.00718.94
8.2.160.0070.00722.96
8.2.150.0070.00025.66
8.2.140.0130.00324.66
8.2.130.0000.00726.16
8.2.120.0000.00826.35
8.2.110.0040.00720.28
8.2.100.0090.00020.40
8.1.280.0070.01125.92
8.1.270.0030.00723.99
8.1.260.0080.00028.09
8.1.250.0040.00428.09
8.1.240.0060.00319.88
8.1.230.0040.00418.87
7.4.80.0040.01416.46
7.4.70.0030.01716.25
7.4.60.0150.00916.41
7.4.50.0070.01116.43
7.4.40.0110.01116.47
7.4.30.0100.01016.27
7.4.20.0080.01216.22
7.4.10.0150.00316.46
7.4.00.0060.01416.26
7.3.200.0070.01716.23
7.3.190.0050.01816.20
7.3.180.0030.01616.40
7.3.170.0070.01316.28
7.3.160.0070.01416.37
7.3.150.0060.01716.43
7.3.140.0090.00916.24
7.3.130.0120.01016.27
7.3.120.0110.00916.12
7.3.110.0120.00816.36
7.3.100.0100.01316.32
7.3.90.0030.01716.25
7.3.80.0080.01116.22
7.3.70.0070.01416.21
7.3.60.0030.01716.29
7.3.50.0070.01716.21
7.3.40.0030.01616.18
7.3.30.0150.00916.19
7.3.20.0030.01716.24
7.3.10.0130.00616.20
7.3.00.0220.00316.18
7.2.320.0170.00316.56
7.2.310.0030.01516.13
7.2.300.0100.01316.47
7.2.290.0130.00616.37
7.2.280.0090.01216.16
7.2.270.0060.01516.24
7.2.260.0100.01116.50
7.2.250.0150.00916.27
7.2.240.0060.01316.14
7.2.230.0100.01416.46
7.2.220.0060.01316.48
7.2.210.0030.01616.48
7.2.200.0100.01316.45
7.2.190.0100.01416.30
7.2.180.0060.01416.43
7.2.170.0090.01216.29
7.2.160.0120.01216.45
7.2.150.0130.00616.61
7.2.140.0060.01316.45
7.2.130.0140.00616.39
7.2.120.0030.02016.37
7.2.110.0070.01616.34
7.2.100.0130.01016.37
7.2.90.0180.01116.25
7.2.80.0060.01616.50
7.2.70.0170.01016.59
7.2.60.0100.01316.41
7.2.50.0130.00616.25
7.2.40.0180.00416.29
7.2.30.0030.01616.55
7.2.20.0030.02016.46
7.2.10.0100.01316.18
7.2.00.0090.01616.45

preferences:
40.54 ms | 400 KiB | 5 Q