3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); namespace Ws\Shared\Users { interface SearchByIdData { public function getId(): int; } abstract class Users { // Add as many abstract methods as needed for any object you need. abstract public function buildSearchByIdData(int $value, string $other): SearchByIdData; public function searchById(int $id, string $otherParam) { $filter = $this->buildSearchByIdData($id, $otherParam); echo 'Do something with ' . get_class($filter) . "\n"; var_dump($filter); } // All other public methods using abstract methods to create objects } } namespace Ws\V1\Users { use Ws\Shared\Users\SearchByIdData as SearchByIdDataInterface; use Ws\Shared\Users\Users as BaseUsers; class SearchByIdDataOption1 { public function __construct(public string $value) {} } class SearchByIdDataOption2 { public function __construct(public string $value) {} } class SearchByIdData implements SearchByIdDataInterface { public function __construct( private int $id, private SearchByIdDataOption1|SearchByIdDataOption2 $option ) {} public function getId(): int { return $this->id; } } class Users extends BaseUsers { public function buildSearchByIdData(int $value, string $other): SearchByIdDataInterface { $option = ($other === 'yes') ? new SearchByIdDataOption1($other) : new SearchByIdDataOption2($other); return new SearchByIdData($value, $option); } } } namespace Ws\V2\Users { use Ws\Shared\Users\SearchByIdData as SearchByIdDataInterface; use Ws\Shared\Users\Users as BaseUsers; class SearchByIdDataOption1 { public function __construct(public string $value) {} } class SearchByIdDataOption2 { public function __construct(public string $value) {} } class SearchByIdData implements SearchByIdDataInterface { public function __construct( private int $id, private SearchByIdDataOption1|SearchByIdDataOption2 $option ) {} public function getId(): int { return $this->id; } } class Users extends BaseUsers { public function buildSearchByIdData(int $value, string $other): SearchByIdDataInterface { $option = ($other === 'yes') ? new SearchByIdDataOption1($other) : new SearchByIdDataOption2($other); return new SearchByIdData($value, $option); } } } namespace Somewhere\Else { // Using v1: $v1Users = new \Ws\V1\Users\Users(); $v1Users->searchById(1, 'yes'); $v1Users->searchById(1, 'maybe'); // Using v2: $v2Users = new \Ws\V2\Users\Users(); $v2Users->searchById(1, 'yes'); $v2Users->searchById(1, 'maybe'); }

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.5.10.0110.00619.63
8.5.00.0130.01020.14
8.4.150.0020.00014.05
8.4.140.0120.01117.54
8.4.130.0130.00419.42
8.4.120.0110.00624.09
8.4.110.0110.00822.55
8.4.100.0130.00718.73
8.4.90.0160.00519.09
8.4.80.0060.00318.70
8.4.70.0110.00617.99
8.4.60.0100.01218.82
8.4.50.0070.00718.75
8.4.40.0070.01717.74
8.4.30.0130.00623.83
8.4.20.0170.00319.56
8.4.10.0100.01019.23
8.3.280.0140.00718.51
8.3.270.0100.01116.69
8.3.260.0120.00816.49
8.3.250.0110.00419.18
8.3.240.0140.00417.02
8.3.230.0140.00516.56
8.3.220.0110.00518.98
8.3.210.0120.00818.31
8.3.200.0060.00316.80
8.3.190.0100.00917.23
8.3.180.0110.01017.30
8.3.170.0180.00317.30
8.3.160.0130.00720.76
8.3.150.0110.00717.20
8.3.140.0160.00316.85
8.3.130.0000.00916.84
8.3.120.0120.00518.31
8.3.110.0090.00018.49
8.3.50.0060.00318.33
8.2.290.0140.00520.37
8.2.280.0130.00818.31
8.2.270.0100.00016.56
8.2.260.0040.01116.57
8.2.250.0060.00316.88
8.2.240.0110.00718.45
8.2.230.0070.00318.31
8.2.220.0050.00516.42
8.1.330.0090.01021.99
8.1.320.0110.00816.21
8.1.310.0110.00716.97
8.1.300.0060.00316.01

preferences:
33.35 ms | 403 KiB | 5 Q