3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Subject { // valid return types public function int(): int; public function bool(): bool; public function array(): array; public function float(): float; public function string(): string; public function iterable(): iterable; public function callable(): callable; public function void(): void; public function object(): object; public function mixed(): mixed; // invalid return types public function self(): self; public function integer(): integer; public function boolean(): boolean; public function double(): double; public function resource(): resource; } interface Subject2 { // valid return types PUBLIC FUNCTION INT(): INT; PUBLIC FUNCTION BOOL(): BOOL; PUBLIC FUNCTION ARRAY(): ARRAY; PUBLIC FUNCTION FLOAT(): FLOAT; PUBLIC FUNCTION STRING(): STRING; PUBLIC FUNCTION ITERABLE(): ITERABLE; PUBLIC FUNCTION CALLABLE(): CALLABLE; PUBLIC FUNCTION VOID(): VOID; PUBLIC FUNCTION OBJECT(): OBJECT; PUBLIC FUNCTION MIXED(): MIXED; PUBLIC FUNCTION SELF(): SELF; // invalid return types PUBLIC FUNCTION INTEGER(): INTEGER; PUBLIC FUNCTION BOOLEAN(): BOOLEAN; PUBLIC FUNCTION DOUBLE(): DOUBLE; PUBLIC FUNCTION RESOURCE(): RESOURCE; } test(Subject::class); test(Subject2::class); /** * @param class-string $class */ function test(string $class): void { $result = []; $ref = new ReflectionClass($class); foreach ($ref->getMethods() as $ref_method) { $name = $ref_method->getName(); $type = $ref_method->getReturnType(); $is_valid = $type instanceof ReflectionNamedType && $type->isBuiltin(); $key = $is_valid ? 'valid' : 'invalid'; $type_name = $type instanceof ReflectionNamedType ? $type->getName() : null; if ($type_name && $name !== $type_name) { $name = "{$name} -> {$type_name}"; } $result[$key][] = $name; } echo $class, ' ', json_encode($result, JSON_PRETTY_PRINT), PHP_EOL; }

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.20.0170.00319.88
8.4.10.0130.00719.63
8.3.150.0100.01017.22
8.3.140.0030.00617.27
8.3.130.0040.00418.48
8.3.120.0090.00620.64
8.3.110.0030.00516.75
8.3.100.0050.00518.72
8.3.90.0040.00426.77
8.3.80.0060.00318.68
8.3.70.0120.00316.63
8.3.60.0040.01518.68
8.3.50.0070.01018.13
8.3.40.0140.00322.09
8.3.30.0040.01118.84
8.3.20.0000.00824.18
8.3.10.0030.00524.66
8.3.00.0080.00026.16
8.2.260.0070.01116.82
8.2.250.0000.00816.89
8.2.240.0030.00617.38
8.2.230.0040.00420.94
8.2.220.0080.00037.54
8.2.210.0030.00526.77
8.2.200.0070.00318.41
8.2.190.0150.00016.88
8.2.180.0120.00325.92
8.2.170.0060.01019.13
8.2.160.0100.00722.96
8.2.150.0000.00725.66
8.2.140.0060.00324.66
8.2.130.0000.00726.16
8.2.120.0000.00821.14
8.2.110.0030.00620.40
8.2.100.0040.00720.27
8.1.310.0080.00018.74
8.1.300.0060.00318.38
8.1.290.0060.00330.84
8.1.280.0110.00725.92
8.1.270.0050.00323.92
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0030.00620.24
8.1.230.0050.00518.63
8.1.50.0130.00517.48
8.0.180.0070.00716.93
8.0.100.0030.00616.79

preferences:
38.69 ms | 403 KiB | 5 Q