Skip to content
Advertisement

PHP var_dump() in xdebug ignores __debugInfo() magical method

Xdebug seems to ignore PHP magic method __debugInfo() in user defined classes when using var_dump().

This is especially unhandy when injecting dependencies (with dependencies, with dependencies…).

Is there a setting for Xdebug’s var_dump() so it works with __debugInfo() as expected? Or a workaround in PHP maybe? I could not find anything.

Advertisement

Answer

Xdebug’s philosophy is to show data as it exists in objects, to aid debugging. Having all the properties shown, and not just the ones that __debugInfo() returns follows this convention.

There is a workaround for step debugging, but not for the overloaded var_dump(). You can turn off Xdebug’s “Development Tools” however, by not including develop in the xdebug.mode php.ini setting.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement