3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface I { public function a(int $a): string; } Class C implements I { public function a(int|string $a): string { return "foo"; } } class D implements I { public function a(int $a): string { return "foo"; } } /** * `test` from previous example (https://3v4l.org/5YPdg) does not respect I. * It calls with a string instead of an int (which is what I requires), thus the $subject->a() * call will fail at runtime for any implementation of I that doesn't widen the type. */ function ignores_i(I $subject) { print $subject->a("beep"); } /** * This implementation respects the interface--the $subject->a() call will * _never_ result in a type error at runtime */ function respects_i(I $subject) { print $subject->a(123); } /** * Widening int => int|string _is_ useful, becacuse we can also write code against * this concrete type, and here we _can_ safely pass a string. */ function uses_concrete_type(C $subject) { $subject->a("beep"); } respects_i(new C()); // works respects_i(new D()); // works uses_concrete_type(new C()); // works ignores_i(new C()); // works ignores_i(new D()); // type error

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.4.120.0140.00618.77
8.4.110.0120.00418.87
8.4.100.0120.00917.96
8.4.90.0040.00420.75
8.4.80.0090.00820.34
8.4.70.0080.00920.48
8.4.60.0110.01017.64
8.4.50.0150.00719.64
8.4.40.0380.01017.55
8.4.30.0380.01117.32
8.4.20.0370.01217.70
8.4.10.0370.01017.58
8.3.250.0100.01117.08
8.3.240.0130.00616.71
8.3.230.0150.00417.20
8.3.220.0060.00218.96
8.3.210.0100.00816.86
8.3.200.0070.00216.96
8.3.190.0330.00816.54
8.3.180.0390.00616.35
8.3.170.0360.01016.41
8.3.160.0290.00616.89
8.3.150.0370.00716.23
8.3.140.0390.01216.67
8.3.130.0350.00816.75
8.3.120.0310.01016.53
8.3.110.0280.01016.51
8.3.100.0260.00116.60
8.3.90.0170.00616.38
8.3.80.0180.00316.68
8.3.70.0220.00416.46
8.3.60.0210.01016.26
8.3.50.0360.01216.31
8.3.40.0280.01217.66
8.3.30.0290.01217.28
8.3.20.0360.00717.40
8.3.10.0250.00717.70
8.3.00.0230.00418.97
8.2.290.0120.00816.86
8.2.280.0350.00716.57
8.2.270.0350.00716.20
8.2.260.0300.00916.41
8.2.250.0280.01116.49
8.2.240.0300.00816.69
8.2.230.0320.00816.58
8.2.220.0300.01016.61
8.2.210.0300.00516.33
8.2.200.0300.00916.49
8.2.190.0340.00716.45
8.2.180.0300.00816.63
8.2.170.0350.00817.57
8.2.160.0340.01017.68
8.2.150.0320.01517.32
8.2.140.0300.01017.32
8.2.130.0370.00717.65
8.2.120.0350.00917.42
8.2.110.0370.00717.70
8.2.100.0360.00617.51
8.2.90.0330.00717.61
8.2.80.0320.00917.52
8.2.70.0300.01217.33
8.2.60.0350.00817.42
8.2.50.0380.00817.43
8.2.40.0340.00417.46
8.2.30.0230.01317.56
8.2.20.0350.00817.59
8.2.10.0340.00717.59
8.2.00.0310.00817.14

preferences:
26.13 ms | 403 KiB | 5 Q