Open
Description
Description
Following #48432 (review)
It would be helpful to pass options to the dump()
and dd()
functions.
- @nicolas-grekas propose to use named arguments, and an option builder.
$options = VarDumper::options()->trace()->maxDepth(4)->toArray();
dump($var, ...$options);
// or
dump($var, _trace: true, _max_depth: 4);
The underscore prefix is required to prevent conflict with named arguments that could be dynamically set.
- In addition, I propose to return the options builder and actually display the dump in a
__destruct
. So that it is more fluent.
dump($var)->trace()->maxDepth(4);
A last method can be added in case the __destruct
would not be called (return value affected to a variable).
dump($var)->trace()->maxDepth(4)->render();
To be complete, we need the same capability for the dump
helper in Twig.
Example
No response