3v4l.org

run code in 300+ PHP versions simultaneously
<?php final readonly class Client { public function __construct( private string $a, private string $very, private string $long, private string $list, private string $of, private string $constructor, private string $argument, private string $userAgent, ) { } public function fetch(int $id): array { var_dump("fetching user $id"); // Simulate fetching from remote service $this->userAgent; return [ 'id' => $id, 'name' => 'John Doe', ]; } public function getName(): string { return 'The Super API Client'; } } final readonly class UserRepository { public function __construct( public Client $client, ) { } public function find(int $id): array { return $this->client->fetch($id); } } $reflector = new ReflectionClass(Client::class); $client = $reflector->newLazyProxy(function ($x) { var_dump("init"); return new Client( 'a', 'very', 'long', 'list', 'of', 'constructor', 'argument', 'Mozilla/5.0', ); }); $repository = new UserRepository($client); var_dump($repository->client->getName()); var_dump($repository->find(42));
Output for git.master, git.master_jit
string(20) "The Super API Client" string(16) "fetching user 42" string(4) "init" array(2) { ["id"]=> int(42) ["name"]=> string(8) "John Doe" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
34.26 ms | 405 KiB | 5 Q