Skip to content

Latest commit

 

History

History
65 lines (60 loc) · 2.53 KB

File metadata and controls

65 lines (60 loc) · 2.53 KB

1. Usage

1.1. What are filters?

Filters define which properties will be output by var_dump. You can use multiple filters for one class. Filters are defined at class level.

1.2. Use filters

#[AddFilter(All:class)]
class Test
{
    use ModifiedDump;

    private $a;
    private $b;
}

To use multiple filters just use multiple AddFilter attributes.

1.3. Default filter

The default filter is OnlyWithDumpAttribute, which requires properties to be attributes with #[Dump]

2. Custom filters

2.1. Create the filter

Filters have to implement the interface \Berbeflo\ModifyDump\Filter\Filter, which defines the method isAllowed with the signature isAllowed(ReflectionProperty $property, object $context): bool. If the property should be displayed, the method has to return true.
It also defines the method create which must return the filter instance.

2.2. Use the filter

Use the full qualified class name as argument for the AddFilter attribute.

3. Implemented filters

3.1. All

A dummy filter if you don't want to exclude any properties. Always returns true.

3.2. NoPassword

A filter that exludes properties with the names password, pw and pass. Underscores will be ignored.

3.3. NoPrivate

A filter that excludes all private properties.

3.4. NoProtected

A filter that excludes all protected properties.

3.5. NoPublic

A filter that excludes all public properties.

3.6. NoUninitialized

A filter that excludes all properties that aren't initialized.

3.7. OnlyWithDumpAttribute

A filter that excludes all properties that are not attributed with #[Dump].

3.8. OnlyWithoutNoDumpAttribute

A filter that excludes all properties that are attributed with #[NoDump].

4. Navigation