3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User {}; class UserList { private $list = []; public function __construct(User ...$user) { $this->list = $user; } public function add(User $user) { $this->list[] = $user; } public function all(): array { return $this->list; } } // // Usage // $userList = new UserList(new User(), new User()); $userList->add(new User()); print_r($userList->all());
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
Array ( [0] => User Object ( ) [1] => User Object ( ) [2] => User Object ( ) )

preferences:
167.55 ms | 403 KiB | 163 Q