Levi Pike
Levi Pike

Reputation: 195

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.

Upvotes: 0

Views: 176

Answers (1)

Derick
Derick

Reputation: 36774

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.

Upvotes: 1

Related Questions