3v4l.org

run code in 500+ PHP versions simultaneously
<?php class User {} function handle(User ...$userList) { print count($userList)." users\n"; /** ... */ } $bunchOfUsers = [ new User(), new User(), ]; echo handle(...$bunchOfUsers); $bunchOfUsers[] = 1; echo handle(...$bunchOfUsers); // error!$bunchOfUsers
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.7
2 users Fatal error: Uncaught TypeError: handle(): Argument #3 must be of type User, int given, called in /in/Ov9mJ on line 18 and defined in /in/Ov9mJ:5 Stack trace: #0 /in/Ov9mJ(18): handle(Object(User), Object(User), 1) #1 {main} thrown in /in/Ov9mJ on line 5
Process exited with code 255.

preferences:
58.23 ms | 878 KiB | 4 Q