How can I examine the argument variables for Kirby hooks?

I’m trying to make use of the arguments used in the default Kirby hooks. e.g:

'user.update:after' => function ($newUser, $oldUser) {
// echo $newUser :heavy_multiplication_x:
// echo $newUser->toString(); :heavy_multiplication_x:
// var_dump($newUser) :heavy_multiplication_x:
// echo json_encode($newUser) :heavy_multiplication_x:

I wanted to take a look at the structure of $newUser and $oldUser so I can write a function to compare them, but any kind of attempt to display gives:

Exception: undefined
The JSON response from the API could not be parsed. Please check your API connection.

How can I take a look at the structure of $newUser, $oldUser (and other similar objects from hook arguments) when I update the page so I can then design my methods around them?

Many thanks.

If you don’t use Xdebug, you could write the dump to file. You will still end up with an error message in the Panel, but the dump will nevertheless be written to file. error_log() might work as well, it would write to your error log file (not tested).

F::write( kirby()->root('index') . '/log.txt', dump( $newPage ) );

I’m not 100% sure anymore, but I think if you run dump($newUser); in a hook you could see it in the browser devtools console.