leo icon indicating copy to clipboard operation
leo copied to clipboard

better alternative to print_r?

Open brianium opened this issue 10 years ago • 2 comments

The Formatter class uses print_r($var, true) to format an object by default.

This works most of the time, but will result in an endless stream of garbage if the variable contains circular references.

The symfony VarDumper component looks pretty promising. Seems like it allows you to limit depth.

brianium avatar Feb 11 '15 15:02 brianium

This could even be an additional formatter that can be used in place of the default one.

brianium avatar Feb 11 '15 15:02 brianium

Another problem with print_r is that it doesn't differentiate types at all.

This code:

expect(1)->to->equal(1.0);

Produces this output:

Expected 1 to be identical to 1

mallorydxw avatar May 05 '17 18:05 mallorydxw