3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param array{id: string, name: string} $user * @return array{id: string, name: string} */ function takesUserData(array $user): array { $user['extra_data'] = new stdClass(); return $user; } $foo = ['id' => 'DP42', 'name' => 'Douglas Adams']; echo implode('', takesUserData($foo));

preferences:
25.4 ms | 404 KiB | 5 Q