Formatters are used to change the output of properties.
class Test
{
use ModifiedDump;
#[Dump(Formatter::class)]
private $a;
}To use a formatter, just pass it's full qualified class name to the #[Dump] attribute.
The default formatter is the Formatter class, which returns the property name as identifier and the property value as value. If a property is uninitialized, an instance of Uninitialized will be returned.
To change the default formatter, use the #[Option] attribute on class level:
#[Option('default-formatter', AccessModifierFormatter::class)]
class Test
{
use ModifiedDump;
private $a;
}Formatters have to extend the class \Berbeflo\ModifyDump\Formatter\Formatter.php. The method getIdentifier returns the identifier, which will be displayed on var_dump. The method getValue returns the value, which will be displayed on var_dump.
Use the full qualified class name as argument for the Dump attribute.
This formatter returns the method name with prefixed
+for public properties#for protected properties-for private properties