peridot-php / leo

Next level assertion and matcher library for PHP

Home Page:http://peridot-php.github.io/leo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

better alternative to print_r?

brianium opened this issue · 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.

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

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