3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { public function __construct(public int $id) {} } class Admin { public function __construct(public int $id) {} } /** * @param User[] $users */ function deleteUsers(array $users) { $typedArray = (fn (User ...$users) => $users)(...$users); foreach ($typedArray as $user) { var_dump($user->id); } } deleteUsers([new User(1), new User(2), new User(3)]); deleteUsers([new User(4), new Admin(5), new User(6)]);
Output for git.master_jit, git.master
int(1) int(2) int(3) Fatal error: Uncaught TypeError: {closure:deleteUsers():11}(): Argument #2 must be of type User, Admin given, called in /in/fjrcM on line 11 and defined in /in/fjrcM:11 Stack trace: #0 /in/fjrcM(11): {closure:deleteUsers():11}(Object(User), Object(Admin), Object(User)) #1 /in/fjrcM(19): deleteUsers(Array) #2 {main} thrown in /in/fjrcM on line 11
Process exited with code 255.
Output for rfc.property-hooks
int(1) int(2) int(3) Fatal error: Uncaught TypeError: {closure}(): Argument #2 must be of type User, Admin given, called in /in/fjrcM on line 11 and defined in /in/fjrcM:11 Stack trace: #0 /in/fjrcM(11): {closure}(Object(User), Object(Admin), Object(User)) #1 /in/fjrcM(19): deleteUsers(Array) #2 {main} thrown in /in/fjrcM on line 11
Process exited with code 255.

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:
26.56 ms | 407 KiB | 5 Q