3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait CastableBehavior { public static function getFromContext($obj) { $casted = new static; foreach (get_object_vars($obj) as $key => $value) { echo $key, '=>', $value, PHP_EOL; $casted->$key = $value; } return $casted; } } interface UserTypes { const USER = 1; const ADMIN = 2; const MODERATOR = 3; } class User { private $id; private $name; private $type; public function __construct($id, $name, $type) { $this->id = $id; $this->name = $name; $this->type = $type; } public function getID() { return $this->id; } public function getName() { return $this->name; } public function getType() { return $this->type; } } class Admin { use CastableBehavior; private $id; private $name; private $type; } $user = new User(2, 'John', UserTypes::ADMIN); if ($user->getType() === UserTypes::ADMIN) { $admin = Admin::getFromContext($user); } var_dump($admin);

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.0120.00316.75
8.3.50.0140.00522.00
8.3.40.0040.01118.79
8.3.30.0060.00919.21
8.3.20.0000.00720.29
8.3.10.0060.00321.90
8.3.00.0040.00419.38
8.2.180.0060.00916.50
8.2.170.0110.00422.96
8.2.160.0100.00320.35
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00419.23
8.2.110.0080.00421.06
8.2.100.0060.00617.75
8.2.90.0000.00819.27
8.2.80.0080.00017.97
8.2.70.0030.00917.50
8.2.60.0080.00018.03
8.2.50.0030.00618.07
8.2.40.0040.00419.69
8.2.30.0040.00418.08
8.2.20.0000.00917.65
8.2.10.0000.00818.08
8.2.00.0000.00717.64
8.1.280.0090.00625.92
8.1.270.0080.00020.54
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0050.00522.18
8.1.230.0030.00717.66
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0070.00317.10
8.1.190.0040.00417.35
8.1.180.0030.00618.10
8.1.170.0000.00820.41
8.1.160.0040.00421.95
8.1.150.0030.00518.96
8.1.140.0040.00417.40
8.1.130.0000.00717.96
8.1.120.0070.00017.53
8.1.110.0080.00017.50
8.1.100.0000.00717.48
8.1.90.0040.00417.47
8.1.80.0000.00817.35
8.1.70.0030.00317.52
8.1.60.0070.00317.59
8.1.50.0030.00517.59
8.1.40.0040.00417.46
8.1.30.0000.00817.69
8.1.20.0040.00417.65
8.1.10.0030.00717.46
8.1.00.0000.00817.54
8.0.300.0070.00018.77
8.0.290.0060.00316.75
8.0.280.0040.00418.39
8.0.270.0030.00317.20
8.0.260.0030.00317.21
8.0.250.0000.00816.86
8.0.240.0050.00217.00
8.0.230.0030.00316.91
8.0.220.0000.00716.80
8.0.210.0060.00316.79
8.0.200.0040.00416.90
8.0.190.0040.00416.94
8.0.180.0000.00716.86
8.0.170.0050.00216.88
8.0.160.0040.00416.84
8.0.150.0070.00016.87
8.0.140.0040.00416.89
8.0.130.0000.00613.32
8.0.120.0040.00416.92
8.0.110.0050.00216.83
8.0.100.0000.00716.80
8.0.90.0050.00216.87
8.0.80.0120.00316.88
8.0.70.0000.00716.91
8.0.60.0030.00516.75
8.0.50.0040.00416.71
8.0.30.0140.01117.13
8.0.20.0120.00717.40
8.0.10.0000.00816.99
8.0.00.0070.01116.79
7.4.330.0020.00215.20
7.4.320.0030.00316.64
7.4.300.0080.00016.48
7.4.290.0000.00716.69
7.4.280.0000.00716.51
7.4.270.0000.00716.50
7.4.260.0000.00816.65
7.4.250.0040.00416.39
7.4.240.0020.00516.60
7.4.230.0020.00516.43
7.4.220.0070.01116.54
7.4.210.0070.00816.54
7.4.200.0030.00316.52
7.4.160.0210.00316.58
7.4.150.0060.01217.40
7.4.140.0110.01217.86
7.4.130.0110.00716.50
7.4.120.0100.00616.57
7.4.110.0070.01716.57
7.4.100.0090.00916.51
7.4.90.0060.01116.58
7.4.80.0160.00719.39
7.4.70.0090.00916.54
7.4.60.0130.00316.56
7.4.50.0040.00416.43
7.4.40.0040.01416.39
7.4.30.0070.01416.33
7.4.00.0100.00315.01
7.3.330.0000.00513.33
7.3.320.0130.00013.34
7.3.310.0000.00716.25
7.3.300.0000.00616.24
7.3.290.0080.00716.32
7.3.280.0120.00516.31
7.3.270.0080.01117.40
7.3.260.0150.00616.60
7.3.250.0050.01316.35
7.3.240.0060.00916.48
7.3.230.0060.01216.40
7.3.210.0070.01016.46
7.3.200.0090.00919.39
7.3.190.0080.00816.61
7.3.180.0030.01316.31
7.3.170.0070.01016.33
7.3.160.0060.01016.26
7.2.330.0120.00616.79
7.2.320.0060.01116.76
7.2.310.0090.01416.80
7.2.300.0140.00716.61
7.2.290.0140.00816.66
7.2.60.0000.00816.97
7.2.00.0070.00719.27
7.1.200.0030.00615.77
7.1.100.0060.01017.88
7.1.70.0000.00717.19
7.1.60.0130.01319.50
7.1.50.0080.00416.98
7.1.00.0100.07022.35
7.0.200.0240.00316.56
7.0.140.0100.02722.21
7.0.60.0170.06719.98
7.0.50.0130.07717.84
7.0.40.0070.04320.27
7.0.30.0270.05320.07
7.0.20.0270.05720.22
7.0.10.0270.08020.30
7.0.00.0030.09320.09
5.6.210.0130.08020.60
5.6.200.0070.06018.15
5.6.190.0070.08020.60
5.6.180.0270.03720.45
5.6.170.0170.04720.50
5.6.160.0170.07720.48
5.6.150.0130.04318.15
5.6.140.0130.07318.15
5.6.130.0070.07318.18
5.6.120.0000.04721.02
5.6.110.0030.09020.90
5.6.100.0130.07721.11
5.6.90.0030.05720.86
5.6.80.0030.04020.28
5.6.70.0370.06020.54
5.5.350.0230.05720.34
5.5.340.0030.04718.04
5.5.330.0130.04320.46
5.5.320.0070.04320.38
5.5.310.0070.05020.19
5.5.300.0100.03317.95
5.5.290.0100.07718.04
5.5.280.0030.04020.91
5.5.270.0170.05720.89
5.5.260.0130.08020.69
5.5.250.0030.07720.79
5.5.240.0100.07720.13
5.4.450.0900.06319.70
5.4.440.1070.06319.47
5.4.430.0800.07019.69
5.4.420.1030.06319.55
5.4.410.0900.06719.31
5.4.400.0200.07318.51
5.4.390.0270.05718.59
5.4.380.0330.05318.84
5.4.370.0270.05318.75
5.4.360.0170.06318.54
5.4.350.0200.06318.63
5.4.340.0230.05318.52
5.4.320.0200.06318.51
5.4.310.0270.05018.63
5.4.300.0270.06318.62
5.4.290.0170.06018.78
5.4.280.0230.05318.54
5.4.270.0230.05318.70
5.4.260.0330.04718.70
5.4.250.0270.05318.55
5.4.240.0330.05018.55
5.4.230.0370.05018.77
5.4.220.0170.07718.50
5.4.210.0300.05018.79
5.4.200.0200.06016.80
5.4.190.0330.04718.69
5.4.180.0230.06318.79
5.4.170.0200.05718.77
5.4.160.0330.05018.79
5.4.150.0230.05318.73
5.4.140.0070.06716.27
5.4.130.0130.05716.31
5.4.120.0200.05016.30
5.4.110.0230.05316.36
5.4.100.0430.03316.29
5.4.90.0200.05316.23
5.4.80.0270.05316.29
5.4.70.0200.06316.23
5.4.60.0230.04316.20
5.4.50.0230.04716.36
5.4.40.0170.06016.43
5.4.30.0370.06016.14
5.4.20.0270.04716.25
5.4.10.0230.05016.14
5.4.00.0230.05315.71
5.3.290.0270.06714.76
5.3.280.0200.05314.52
5.3.270.0170.06314.60
5.3.260.0230.05314.68
5.3.250.0270.04714.60
5.3.240.0300.04714.66
5.3.230.0270.06714.60
5.3.220.0170.05314.62
5.3.210.0170.06014.54
5.3.200.0230.05314.58
5.3.190.0330.05714.66
5.3.180.0330.04014.46
5.3.170.0130.06314.56
5.3.160.0330.04314.48
5.3.150.0200.05714.56
5.3.140.0130.06314.47
5.3.130.0300.07014.54
5.3.120.0230.07014.51
5.3.110.0170.06314.64
5.3.100.0230.05313.95
5.3.90.0270.05314.02
5.3.80.0200.05014.10
5.3.70.0200.05714.09
5.3.60.0300.04713.93
5.3.50.0370.04013.87
5.3.40.0170.05313.92
5.3.30.0100.07013.88
5.3.20.0200.04713.78
5.3.10.0430.05313.56
5.3.00.0230.05013.57
5.2.170.0270.03711.14
5.2.160.0200.04311.20
5.2.150.0200.04011.09
5.2.140.0170.04311.13
5.2.130.0130.04311.16
5.2.120.0200.04011.05
5.2.110.0230.04311.07
5.2.100.0170.04011.06
5.2.90.0170.04011.12
5.2.80.0200.04011.10
5.2.70.0130.05011.13
5.2.60.0170.04311.01
5.2.50.0230.04011.05
5.2.40.0130.04311.04
5.2.30.0230.03711.03
5.2.20.0100.04710.96
5.2.10.0230.04010.96
5.2.00.0130.04310.75
5.1.60.0200.03310.03
5.1.50.0100.03710.13
5.1.40.0130.03310.02
5.1.30.0230.03310.43
5.1.20.0170.03710.34
5.1.10.0170.03310.13
5.1.00.0100.04010.12
5.0.50.0070.0308.61
5.0.40.0100.0278.44
5.0.30.0100.0478.24
5.0.20.0070.0308.39
5.0.10.0100.0308.18
5.0.00.0030.0478.33
4.4.90.0130.0205.93
4.4.80.0070.0235.81
4.4.70.0100.0205.80
4.4.60.0130.0175.80
4.4.50.0100.0275.92
4.4.40.0070.0435.90
4.4.30.0130.0335.85
4.4.20.0100.0305.91
4.4.10.0070.0235.95
4.4.00.0070.0375.85
4.3.110.0070.0235.78
4.3.100.0030.0235.77
4.3.90.0100.0205.88
4.3.80.0030.0475.91
4.3.70.0070.0235.78
4.3.60.0130.0305.78
4.3.50.0130.0275.79
4.3.40.0130.0305.86
4.3.30.0030.0274.58
4.3.20.0030.0234.51
4.3.10.0000.0274.62
4.3.00.0200.0236.67

preferences:
39.63 ms | 401 KiB | 5 Q