mnapoli / number-two
This package is abandoned and no longer maintained.
No replacement package was suggested.
NumberTwo is a classy variable dumper
1.0.0
2013-07-25 07:47 UTC
README
NumberTwo is a classy variable dumper.
When var_dump
or print_r
is too verbose or unpleasant to read, go for NumberTwo.
Scalars
echo NumberTwo::dump(null); // null echo NumberTwo::dump(true); // true echo NumberTwo::dump(false); // false echo NumberTwo::dump(1); // 1 echo NumberTwo::dump('foo'); // "foo"
Arrays
echo NumberTwo::dump(array('foo', 'bar'));
[ 0 => "foo" 1 => "bar" ]
echo NumberTwo::dump(array('foo' => 'bar'));
[ "foo" => "bar" ]
Objects
echo NumberTwo::dump($object);
My\ClassWithPublicProperties { foo: "aaa" bar: "bbb" }
You can configure the recursive depth:
echo NumberTwo::dump($otherObject, 2);
UnitTest\NumberTwo\PublicProperties { foo: UnitTest\NumberTwo\PublicProperties { foo: UnitTest\NumberTwo\PrivateProperties { ... } bar: null } bar: null }
Filters
You may want to pre-process some objects that are to be dumped.
For that, you can use the filters:
$filters = array(new MyFilter()); echo NumberTwo::dump($otherObject, 2, $filters);
Doctrine Collection
NumberTwo provides a filter for Doctrine's collections:
use NumberTwo\Filter\DoctrineCollectionFilter; $filters = array(new DoctrineCollectionFilter()); echo NumberTwo::dump($otherObject, 2, $filters);
This filter will turn any Collection (ArrayCollection, PersistentCollection, …) into a PHP array (using the toArray()
method).
Doctrine proxies
NumberTwo provides a filter for Doctrine's proxies:
use NumberTwo\Filter\DoctrineProxyFilter; $filters = array(new DoctrineProxyFilter()); echo NumberTwo::dump($otherObject, 2, $filters);
This filter will load uninitialized proxies and clean up properties.
Feel free to submit other filters in a pull request.
License
NumberTwo is under the MIT license.