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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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:
115.11 ms | 402 KiB | 121 Q