__debuginfo() must return an array

Hi

I’m trying several ways to debug Hooks as well as custom Fields. But the above-mentioned error raises regularly in these situations:

1. Debugging hooks using var_dump:
That’s the content of config/config.php

c::set('debug', true);

kirby()->hook('panel.page.create', function($page) {
    var_dump($page);
});

kirby()->hook('panel.page.update', function($page, $oldPage) {
    var_dump($page);
    var_dump($oldPage);
});

Whenever I add or update a Page the error occurs.

2. Debugging hooks using xdebug:
That’s the content of config/config.php:

c::set('debug', true);

kirby()->hook('panel.page.create', function($page) {
    $i = 1+1;
    $i++;
});

kirby()->hook('panel.page.update', function($page, $oldPage) {
    $i = 1+1;
    $i++;
});

I’ve set breakpoints at the first line of these functions.
Whenever I add or update a Page the debugger stops at the corresponding breakpoint. But inspecting the local variables is not possible since they are not shown in the debug window. As soon as I step over the error raises again.

3. Debugging custom Filelds with xdebug:
When stopping at a breakpoint in the custom Field’s constructor everything works as expected. But when stopping at a breakpoint in a member function and then stepping over, I observe the same behavior as in 2.

This is an excerpt of my system’s phpinfo():

I observe the same behavior in VS Code with “PHP Debug” as well as in PHPStorm. Interestingly, xdebug works as expected with other PHP projects of mine.

Any ideas in which direction to go to?

Debugging hooks is a bit tricky, as they do not throw any errors. I usually do one of two things:

  • write results to file using f::write()
  • using error_log()

Thanks for the suggestion regarding debugging hooks.
The fact that plugins such as this one exist makes it obvious that hooks are tricky in regards to debugging.

But what about this?

Is there anybody out there using xdebug for kirby development?