3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait CastableBehavior { public static function getFromContext($obj) { var_dump($this);die; $casted = new $this; foreach (get_object_vars($obj) as $key => $value) { $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.70.0090.00618.22
8.3.60.0090.00616.88
8.3.50.0080.01021.96
8.3.40.0040.01518.57
8.3.30.0110.00419.08
8.3.20.0040.00420.29
8.3.10.0050.00321.72
8.3.00.0080.00019.26
8.2.190.0070.00716.75
8.2.180.0070.01616.88
8.2.170.0110.00322.96
8.2.160.0070.01020.39
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00419.36
8.2.110.0060.00319.31
8.2.100.0040.00817.75
8.2.90.0040.00419.08
8.2.80.0060.00317.97
8.2.70.0070.00317.63
8.2.60.0000.00818.03
8.2.50.0060.00318.07
8.2.40.0030.00619.78
8.2.30.0030.00618.14
8.2.20.0050.00317.64
8.2.10.0000.00718.14
8.2.00.0000.00817.69
8.1.280.0060.00925.92
8.1.270.0000.00920.60
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0090.00023.79
8.1.230.0070.00417.66
8.1.220.0040.00417.78
8.1.210.0030.00618.77
8.1.200.0070.00317.36
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0050.00318.64
8.1.160.0000.00822.09
8.1.150.0040.00418.95
8.1.140.0060.00317.46
8.1.130.0040.00417.84
8.1.120.0000.00717.37
8.1.110.0000.00717.50
8.1.100.0050.00217.38
8.1.90.0030.00317.38
8.1.80.0040.00417.31
8.1.70.0000.00717.52
8.1.60.0040.00717.63
8.1.50.0030.00517.50
8.1.40.0070.00317.53
8.1.30.0060.00317.60
8.1.20.0030.00617.57
8.1.10.0000.00817.48
8.1.00.0060.00317.52
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0040.00418.52
8.0.270.0030.00317.33
8.0.260.0000.00617.15
8.0.250.0030.00316.96
8.0.240.0030.00316.93
8.0.230.0040.00416.89
8.0.220.0070.00016.98
8.0.210.0030.00616.81
8.0.200.0030.00317.07
8.0.190.0040.00416.88
8.0.180.0000.00716.87
8.0.170.0040.00416.97
8.0.160.0040.00417.01
8.0.150.0070.00016.80
8.0.140.0040.00416.90
8.0.130.0000.00613.41
8.0.120.0030.00516.82
8.0.110.0000.00716.95
8.0.100.0040.00416.91
8.0.90.0040.00316.82
8.0.80.0060.01717.02
8.0.70.0000.00717.09
8.0.60.0050.00216.96
8.0.50.0000.00717.02
8.0.30.0180.00317.04
8.0.20.0110.00917.40
8.0.10.0050.00216.88
8.0.00.0100.00816.84
7.4.330.0050.00015.14
7.4.320.0000.00716.63
7.4.300.0060.00316.59
7.4.290.0000.00716.58
7.4.280.0050.00216.61
7.4.270.0070.00016.55
7.4.260.0040.00416.43
7.4.250.0000.00716.58
7.4.240.0050.00216.54
7.4.230.0070.00016.41
7.4.220.0120.00616.71
7.4.210.0110.00716.55
7.4.200.0070.00016.51
7.4.160.0060.01016.79
7.4.150.0070.01117.40
7.4.140.0180.00517.86
7.4.130.0120.00616.52
7.4.120.0110.00816.56
7.4.110.0130.01016.41
7.4.100.0120.00616.66
7.4.90.0070.01016.50
7.4.80.0140.00719.39
7.4.70.0030.01416.72
7.4.60.0060.00916.51
7.4.50.0000.00516.64
7.4.40.0130.00616.35
7.4.30.0090.00916.59
7.4.00.0090.00315.09
7.3.330.0000.00513.38
7.3.320.0080.00413.34
7.3.310.0070.00016.36
7.3.300.0000.00716.40
7.3.290.0120.00316.34
7.3.280.0100.00716.32
7.3.270.0190.00617.40
7.3.260.0140.00416.53
7.3.250.0140.00416.57
7.3.240.0090.00616.36
7.3.230.0100.00716.50
7.3.210.0110.00716.44
7.3.200.0030.01319.39
7.3.190.0030.01316.46
7.3.180.0160.00316.52
7.3.170.0120.00616.45
7.3.160.0130.00616.60
7.2.330.0110.00716.50
7.2.320.0030.01616.43
7.2.310.0110.01616.50
7.2.300.0130.00316.48
7.2.290.0090.00916.79
7.2.80.0100.00316.48
7.2.60.0070.01016.88
7.2.00.0100.00319.61
7.1.200.0030.00515.58
7.1.100.0070.00718.13
7.1.70.0040.00717.22
7.1.60.0120.01219.50
7.1.50.0080.01116.84
7.1.00.0000.08022.31
7.0.200.0230.00316.50
7.0.140.0030.07322.15
7.0.60.0130.08019.95
7.0.50.0100.07717.89
7.0.40.0030.04320.23
7.0.30.0330.07020.21
7.0.20.0230.07320.26
7.0.10.0300.04320.09
7.0.00.0100.08020.09
5.6.280.0070.07021.05
5.6.210.0100.05020.52
5.6.200.0170.04318.22
5.6.190.0030.08320.63
5.6.180.0200.08320.45
5.6.170.0270.08020.53
5.6.160.0030.08320.47
5.6.150.0170.07018.19
5.6.140.0100.07718.17
5.6.130.0030.04318.17
5.6.120.0070.05321.03
5.6.110.0130.07721.05
5.6.100.0070.04320.97
5.6.90.0100.07320.96
5.6.80.0000.04320.52
5.6.70.0270.07720.39
5.5.350.0300.07320.39
5.5.340.0100.03717.98
5.5.330.0100.03320.28
5.5.320.0030.08320.25
5.5.310.0230.07020.34
5.5.300.0130.03017.96
5.5.290.0100.07718.09
5.5.280.0070.03720.70
5.5.270.0070.08720.69
5.5.260.0130.06720.87
5.5.250.0030.07020.76
5.5.240.0070.07720.17
5.4.450.0370.06019.34
5.4.440.0830.07719.28
5.4.430.0370.05719.18
5.4.420.1170.06319.46
5.4.410.0900.08319.45
5.4.400.0270.05018.76
5.4.390.0330.05018.53
5.4.380.0330.05718.73
5.4.370.0270.06018.78
5.4.360.0200.06318.74
5.4.350.0200.07018.76
5.4.340.0330.05018.76
5.4.320.0130.07018.76
5.4.310.0370.06718.57
5.4.300.0230.06018.75
5.4.290.0230.06318.73
5.4.280.0370.04318.61
5.4.270.0300.06718.62
5.4.260.0370.05318.78
5.4.250.0270.06018.78
5.4.240.0200.06018.63
5.4.230.0130.06318.82
5.4.220.0130.06318.79
5.4.210.0230.05018.77
5.4.200.0170.05716.58
5.4.190.0300.04318.71
5.4.180.0270.06318.55
5.4.170.0230.07318.40
5.4.160.0230.05318.80
5.4.150.0230.05718.68
5.4.140.0170.05316.46
5.4.130.0230.05016.20
5.4.120.0170.06016.27
5.4.110.0130.05716.30
5.4.100.0170.06316.26
5.4.90.0270.04716.21
5.4.80.0230.04716.42
5.4.70.0300.04316.25
5.4.60.0130.06016.32
5.4.50.0400.06016.43
5.4.40.0170.05716.41
5.4.30.0200.05016.43
5.4.20.0230.05316.39
5.4.10.0330.05316.26
5.4.00.0300.05015.72
5.3.290.0330.07014.60
5.3.280.0200.07314.68
5.3.270.0100.07014.52
5.3.260.0200.06314.51
5.3.250.0170.05714.58
5.3.240.0270.05014.64
5.3.230.0230.05014.61
5.3.220.0070.06714.55
5.3.210.0370.05014.50
5.3.200.0200.06014.64
5.3.190.0230.05714.54
5.3.180.0270.06014.58
5.3.170.0300.04714.55
5.3.160.0230.06314.61
5.3.150.0170.06014.54
5.3.140.0170.05314.49
5.3.130.0370.06314.64
5.3.120.0300.07014.52
5.3.110.0370.06314.64
5.3.100.0200.05013.95
5.3.90.0300.04714.09
5.3.80.0170.05314.00
5.3.70.0070.06713.92
5.3.60.0200.05714.02
5.3.50.0330.05313.93
5.3.40.0230.06713.93
5.3.30.0230.05713.90
5.3.20.0330.05313.79
5.3.10.0270.05013.75
5.3.00.0230.05313.63
5.2.170.0170.04311.19
5.2.160.0130.04711.10
5.2.150.0130.04711.14
5.2.140.0200.04311.29
5.2.130.0100.05011.06
5.2.120.0230.04711.06
5.2.110.0100.04711.06
5.2.100.0230.03711.08
5.2.90.0230.04011.11
5.2.80.0200.04011.05
5.2.70.0170.04011.13
5.2.60.0170.04711.08
5.2.50.0200.04311.05
5.2.40.0130.04011.05
5.2.30.0070.05711.11
5.2.20.0170.04010.96
5.2.10.0230.03010.93
5.2.00.0170.04710.69
5.1.60.0130.03310.07
5.1.50.0170.03310.00
5.1.40.0130.0339.98
5.1.30.0100.04010.47
5.1.20.0030.05010.43
5.1.10.0200.02710.18
5.1.00.0130.04010.12
5.0.50.0100.0278.64
5.0.40.0070.0308.46
5.0.30.0130.0408.25
5.0.20.0070.0308.23
5.0.10.0130.0278.23
5.0.00.0100.0438.15
4.4.90.0070.0235.91
4.4.80.0100.0235.90
4.4.70.0070.0235.90
4.4.60.0100.0275.82
4.4.50.0200.0205.86
4.4.40.0130.0335.86
4.4.30.0100.0275.87
4.4.20.0170.0275.93
4.4.10.0130.0205.92
4.4.00.0070.0435.93
4.3.110.0100.0205.79
4.3.100.0100.0235.80
4.3.90.0130.0205.89
4.3.80.0070.0335.91
4.3.70.0070.0205.79
4.3.60.0200.0175.87
4.3.50.0070.0235.89
4.3.40.0130.0335.76
4.3.30.0000.0274.54
4.3.20.0000.0274.64
4.3.10.0070.0204.56
4.3.00.0100.0236.79

preferences:
71.71 ms | 401 KiB | 5 Q