Get support for mnapoli/NumberTwo

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

mnapoli/NumberTwo

NumberTwo

NumberTwo is a classy variable dumper.

Build Status

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.

Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2