3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * A very edge case in PHP 5.4 regarding passing objects by reference. * It seems to be a compound effect of using reflection to set an inherited method as 'available', * AND that method taking an explicitly referential argument (&argument sig) * AND then invoking it with func_get_args() as opposed to constructing the array of args manually. * * No idea why these things all cause this behaviour or if they should. * * Important to note that this effect isn't present in PHP 5.5. */ class A { private function foo(&$arg1) { var_dump('arg1: ', $arg1); } } class B extends A { public function bar() { $x = new stdClass(); $x->baz = 'just a value'; $this->callPrivate($x); } private function callPrivate($x) { $method = new \ReflectionMethod( 'A', 'foo' ); //* for some reason, the private function needs to have been changed to be 'accessible' for this to work in 5.4 $method->setAccessible(true); //working 5.4 (* see above) but not in 5.5 $arguments = func_get_args(); //not working in either //$arguments = array($x); // <---- COMMENT THIS LINE TO SEE IT WORK IN PHP 5.4 return $method->invokeArgs($this, $arguments); } } $y = new B(); $y->bar();

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.0110.00418.66
8.3.60.0140.00718.43
8.3.50.0100.01022.11
8.3.40.0150.00018.73
8.3.30.0150.00618.95
8.3.20.0080.00020.39
8.3.10.0040.00423.61
8.3.00.0060.00320.94
8.2.180.0120.00417.13
8.2.170.0070.01422.96
8.2.160.0040.01120.52
8.2.150.0090.00624.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0060.00319.18
8.2.110.0090.00019.30
8.2.100.0060.00617.69
8.2.90.0080.00019.23
8.2.80.0000.00817.97
8.2.70.0030.00517.50
8.2.60.0060.00318.04
8.2.50.0030.00618.07
8.2.40.0050.00319.77
8.2.30.0060.00518.14
8.2.20.0000.00717.67
8.2.10.0090.00018.02
8.2.00.0030.00517.68
8.1.280.0100.00625.92
8.1.270.0030.00623.96
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0030.01622.19
8.1.230.0040.00718.83
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0040.00417.36
8.1.190.0000.00817.36
8.1.180.0040.00418.10
8.1.170.0000.00818.43
8.1.160.0040.00422.08
8.1.150.0040.00418.57
8.1.140.0000.00717.47
8.1.130.0050.00317.80
8.1.120.0000.00817.49
8.1.110.0000.00817.37
8.1.100.0040.00417.51
8.1.90.0020.00517.52
8.1.80.0040.00417.46
8.1.70.0030.00517.46
8.1.60.0030.00717.63
8.1.50.0000.00817.48
8.1.40.0030.00617.50
8.1.30.0030.00617.65
8.1.20.0040.00417.55
8.1.10.0050.00317.46
8.1.00.0040.00417.39
8.0.300.0070.00020.14
8.0.290.0060.00316.75
8.0.280.0030.00318.38
8.0.270.0050.00317.29
8.0.260.0000.00617.15
8.0.250.0030.00317.10
8.0.240.0030.00316.98
8.0.230.0040.00416.87
8.0.220.0030.00316.94
8.0.210.0070.00016.90
8.0.200.0060.00016.92
8.0.190.0040.00417.04
8.0.180.0070.00016.98
8.0.170.0060.00317.01
8.0.160.0050.00316.96
8.0.150.0000.00716.82
8.0.140.0040.00416.91
8.0.130.0080.00013.41
8.0.120.0000.00816.95
8.0.110.0000.00816.84
8.0.100.0070.00017.04
8.0.90.0050.00316.79
8.0.80.0060.00916.96
8.0.70.0000.00716.96
8.0.60.0000.00717.02
8.0.50.0070.00016.81
8.0.30.0120.00717.24
8.0.20.0060.01317.40
8.0.10.0050.00316.98
8.0.00.0110.00616.70
7.4.330.0020.00215.00
7.4.320.0050.00516.59
7.4.300.0000.00616.51
7.4.290.0000.00716.66
7.4.280.0050.00516.61
7.4.270.0030.00316.49
7.4.260.0050.00216.57
7.4.250.0070.00016.58
7.4.240.0030.00416.50
7.4.230.0030.00316.42
7.4.220.0070.01016.73
7.4.210.0030.01416.52
7.4.200.0000.00716.63
7.4.160.0090.00616.69
7.4.150.0000.01717.40
7.4.140.0120.00617.86
7.4.130.0110.00616.61
7.4.120.0070.00916.57
7.4.110.0150.00316.55
7.4.100.0060.01216.66
7.4.90.0120.00616.62
7.4.80.0150.00419.39
7.4.70.0130.00916.51
7.4.60.0150.00616.48
7.4.50.0070.00016.73
7.4.40.0090.00916.64
7.4.30.0070.01116.37
7.4.00.0030.00814.99
7.3.330.0000.00713.40
7.3.320.0050.00313.23
7.3.310.0000.00716.40
7.3.300.0000.00716.33
7.3.290.0100.01016.52
7.3.280.0110.01016.39
7.3.270.0100.01317.40
7.3.260.0180.00316.39
7.3.250.0040.01416.49
7.3.240.0100.00716.39
7.3.230.0110.00516.39
7.3.210.0130.00616.59
7.3.200.0070.01019.39
7.3.190.0150.00316.41
7.3.180.0100.00716.32
7.3.170.0050.01116.36
7.3.160.0030.01316.43
7.3.120.0080.00414.86
7.2.330.0150.00316.70
7.2.320.0090.01216.43
7.2.310.0170.00016.64
7.2.300.0040.01416.69
7.2.290.0090.00916.64
7.2.60.0090.00616.89
7.2.00.0000.01119.23
7.1.200.0300.00315.65
7.1.100.0130.00717.98
7.1.70.0040.00416.92
7.1.60.0030.02119.70
7.1.50.0130.00617.08
7.1.00.0030.09022.48
7.0.200.0030.00316.63
7.0.140.0070.07022.00
7.0.60.0170.02719.86
7.0.50.0100.07717.95
7.0.40.0170.03020.13
7.0.30.0400.07020.26
7.0.20.0500.06320.33
7.0.10.0230.08020.23
7.0.00.0100.05320.06
5.6.280.0100.06720.86
5.6.210.0100.08320.55
5.6.200.0030.06718.12
5.6.190.0070.05720.42
5.6.180.0200.05020.60
5.6.170.1330.03720.47
5.6.160.0030.09020.50
5.6.150.0030.08718.27
5.6.140.0030.08018.16
5.6.130.0070.07318.21
5.6.120.0170.07321.02
5.6.110.0130.07320.98
5.6.100.0100.07721.11
5.6.90.0000.04320.97
5.6.80.0070.05320.43
5.6.70.4730.04020.39
5.5.350.0100.04720.34
5.5.340.0030.06717.99
5.5.330.0070.05020.37
5.5.320.0270.08720.19
5.5.310.0330.08320.34
5.5.300.0100.08017.99
5.5.290.0070.08018.04
5.5.280.0100.03320.97
5.5.270.0030.08720.90
5.5.260.0000.09320.89
5.5.250.0100.03320.51
5.5.240.0030.04720.37
5.4.450.0230.05719.39
5.4.440.0200.06319.32
5.4.430.0270.07719.57
5.4.420.0200.07719.26
5.4.410.0270.07719.04
5.4.400.0230.04319.27
5.4.390.0200.06019.22
5.4.380.0230.05319.09
5.4.370.0200.04019.22
5.4.360.0200.03319.07
5.4.350.0170.03719.09
5.4.340.0200.03719.13
5.4.320.0200.03719.31
5.4.310.0200.05319.22
5.4.300.0200.03718.87
5.4.290.0230.03319.08
5.4.280.0130.04019.24
5.4.270.0170.04018.99
5.4.260.0230.03318.85
5.4.250.0230.03019.17
5.4.240.0230.04019.13
5.4.230.0100.04019.09
5.4.220.0170.03319.30
5.4.210.0200.03319.22
5.4.200.0200.03719.01
5.4.190.0100.04319.15
5.4.180.0200.03319.07
5.4.170.0170.03719.18
5.4.160.0170.03719.22
5.4.150.0170.03718.84
5.4.140.0130.04016.40
5.4.130.0130.04016.54
5.4.120.0200.03016.39
5.4.110.0170.03716.42
5.4.100.0130.05716.50
5.4.90.0170.03716.30
5.4.80.0300.03716.44
5.4.70.0230.04016.44
5.4.60.0330.06016.51
5.4.50.0300.06316.25
5.4.40.0330.06316.32
5.4.30.0300.03716.51
5.4.20.0300.06716.53
5.4.10.0230.05716.25
5.4.00.0270.05715.78
5.3.290.0270.06714.68
5.3.280.0170.04714.61
5.3.270.0230.03014.66
5.3.260.0200.04014.69
5.3.250.0200.03314.52
5.3.240.0300.03314.53
5.3.230.0300.02714.72
5.3.220.0130.03714.54
5.3.210.0170.04314.56
5.3.200.0230.03014.49
5.3.190.0130.06014.59
5.3.180.0330.05014.57
5.3.170.0330.04014.64
5.3.160.0200.04714.72
5.3.150.0300.06314.72
5.3.140.0270.06014.54
5.3.130.0270.07314.60
5.3.120.0270.05014.59
5.3.110.0330.06314.77
5.3.100.0400.06314.16
5.3.90.0370.06014.25
5.3.80.0330.05014.14
5.3.70.0270.05314.19
5.3.60.0430.03713.99
5.3.50.0300.06013.95
5.3.40.0330.06314.03
5.3.30.0230.07314.07
5.3.20.0300.06713.79
5.3.10.0300.05013.75
5.3.00.0300.05713.65
5.2.170.0170.03311.93
5.2.160.0300.05711.93
5.2.150.0300.04711.93
5.2.140.0170.03711.93
5.2.130.0270.05011.93
5.2.120.0270.05711.93
5.2.110.0230.05011.93
5.2.100.0200.04311.93
5.2.90.0230.06011.93
5.2.80.0370.05311.93
5.2.70.0270.03311.93
5.2.60.0200.06311.93
5.2.50.0230.05311.93
5.2.40.0200.03711.93
5.2.30.0170.04011.93
5.2.20.0200.06011.93
5.2.10.0130.03711.93
5.2.00.0270.04311.93
5.1.60.0200.04711.93
5.1.50.0200.05311.93
5.1.40.0200.04711.93
5.1.30.0130.04011.93
5.1.20.0370.05311.93
5.1.10.0200.05011.93
5.1.00.0230.02711.93
5.0.50.0130.04011.93
5.0.40.0070.03711.93
5.0.30.0200.04711.93
5.0.20.0100.02711.93
5.0.10.0030.04011.93
5.0.00.0100.04711.93
4.4.90.0070.02011.93
4.4.80.0100.02311.93
4.4.70.0100.02311.93
4.4.60.0100.01711.93
4.4.50.0130.02711.93
4.4.40.0070.04311.93
4.4.30.0100.03311.93
4.4.20.0130.03311.93
4.4.10.0200.02011.93
4.4.00.0070.04011.93
4.3.110.0130.03011.93
4.3.100.0100.01711.93
4.3.90.0070.03311.93
4.3.80.0170.02011.93
4.3.70.0070.03711.93
4.3.60.0130.01711.93
4.3.50.0130.02711.93
4.3.40.0070.04011.93
4.3.30.0070.03011.93
4.3.20.0100.02311.93
4.3.10.0030.02311.93
4.3.00.0030.03311.93

preferences:
61.33 ms | 401 KiB | 5 Q