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));
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/PoVil:13 Stack trace: #0 /in/PoVil(13): implode('', Array) #1 {main} thrown in /in/PoVil on line 13
Process exited with code 255.

preferences:
67.18 ms | 406 KiB | 5 Q