3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B {} class C {} class D {} class Z { use ConstructorParamDeprecationHelper; public function __construct( protected A $a, protected C|B $c, protected D|C $d, ) { $this->deprecateParam(B::class, 'c', func_get_args()); var_dump(get_class($this->a)); var_dump(get_class($this->c)); var_dump(get_class($this->d)); } } new Z(new A(), new B(), new C(), new D()); new Z(new A(), new C(), new D()); trait ConstructorParamDeprecationHelper { function deprecateParam($className, $paramName, $args) { if ($this->$paramName instanceof $className) { trigger_error('A, B, C, D is deprecated, pass A, C, D instead', E_USER_DEPRECATED); $constructor = new ReflectionMethod($this, '__construct'); $params = $constructor->getParameters(); $position = array_search($paramName, array_column($params, 'name')); $move = array_slice($params, $position); foreach ($move as $i => $param) { if ($constructor->getNumberOfParameters() > ($i + $position + 1)) { $next = $move[$i + 1]; $this->{$param->getName()} = $this->{$next->getName()}; } else { $this->{$param->getName()} = $args[$i + $position + 1]; } } } } }

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.130.0060.00318.53
8.3.120.0120.00620.80
8.3.110.0060.00920.94
8.3.100.0060.00924.06
8.3.90.0050.00526.77
8.3.80.0000.01117.97
8.3.70.0040.01116.84
8.3.60.0060.01218.80
8.3.50.0000.01516.82
8.3.40.0070.01122.03
8.3.30.0110.00419.21
8.3.20.0040.00424.18
8.3.10.0050.00224.66
8.3.00.0080.00026.16
8.2.250.0070.00316.62
8.2.240.0080.00817.06
8.2.230.0060.00322.58
8.2.220.0060.00337.54
8.2.210.0040.00426.77
8.2.200.0030.00618.66
8.2.190.0090.00916.75
8.2.180.0130.00616.63
8.2.170.0090.00919.04
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0030.00524.66
8.2.130.0050.00326.16
8.2.120.0040.00419.61
8.2.110.0070.00322.31
8.2.100.0060.00617.97
8.2.90.0080.00417.88
8.2.80.0230.00817.48
8.2.70.0260.00417.38
8.2.60.0190.01117.63
8.2.50.0230.00617.23
8.2.40.0210.00617.38
8.2.30.0220.00617.75
8.2.20.0210.00717.34
8.2.10.0210.00717.50
8.2.00.0240.00417.38
8.1.300.0050.00316.23
8.1.290.0030.00630.84
8.1.280.0140.00325.92
8.1.270.0080.00024.66
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00319.09
8.1.230.0070.00420.97
8.1.220.0240.00517.13
8.1.210.0270.00617.13
8.1.200.0280.00616.80
8.1.190.0240.00617.00
8.1.180.0200.00717.11
8.1.170.0190.00817.35
8.1.160.0160.01217.13
8.1.150.0130.01417.25
8.1.140.0270.00017.13
8.1.130.0170.01017.13
8.1.120.0240.00317.13
8.1.110.0230.00317.46
8.1.100.0220.00716.88
8.1.90.0230.00417.50
8.1.80.0170.00917.38
8.1.70.0260.00017.38
8.1.60.0200.00717.34
8.1.50.0240.00317.25
8.1.40.0290.00017.24
8.1.30.0260.00317.22
8.1.20.0230.00317.50
8.1.10.0210.00617.25
8.1.00.0270.00017.38
8.0.300.0230.00516.80
8.0.290.0220.00716.80
8.0.280.0210.00616.80
8.0.270.0290.00016.80
8.0.260.0200.00916.80
8.0.250.0200.01016.80
8.0.240.0240.00416.80
8.0.230.0230.00616.80
8.0.220.0260.00216.80
8.0.210.0240.00716.80
8.0.200.0320.00016.80
8.0.190.0300.00316.80
8.0.180.0240.00716.80
8.0.170.0200.00716.86
8.0.160.0160.01216.80
8.0.150.0210.00916.80
8.0.140.0230.00516.80
8.0.130.0180.00916.80
8.0.120.0230.00516.80
8.0.110.0240.00316.80
8.0.100.0270.00016.80
8.0.90.0180.01116.80
8.0.80.0170.01016.80
8.0.70.0190.00916.80
8.0.60.0220.00616.80
8.0.50.0210.00716.80
8.0.30.0210.00616.80
8.0.20.0130.01416.80
8.0.10.0240.00416.80

preferences:
18.91 ms | 403 KiB | 5 Q