Skip to content

Commit 23712fb

Browse files
more accurate doc about limits
1 parent c578fe7 commit 23712fb

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

components/var_dumper/advanced.rst

+19-14
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,27 @@ Cloners
1010

1111
A cloner is used to create an intermediate representation of any PHP variable.
1212
Its output is a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data`
13-
object that wraps this representation. A cloner also applies limits when
14-
creating the representation, so that the corresponding Data object could
15-
represent only a subset of the cloned variable.
13+
object that wraps this representation.
1614

1715
You can create a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data`
1816
object this way::
1917

2018
$cloner = new VarCloner();
2119
$data = $cloner->cloneVar($myVar);
2220

23-
Before cloning, you can configure the limits with::
21+
A cloner also applies limits when creating this representation, so that the
22+
corresponding Data object could represent only a subset of the cloned variable.
23+
Before :method:`Symfony\\Component\\VarDumper\\Cloner\\VarCloner::cloneVar`,
24+
you can configure these limits:
2425

25-
$cloner->setMaxItems($number);
26-
$cloner->setMaxString($number);
27-
28-
They will be applied when calling ``->cloneVar()`` afterwards.
26+
* :method:`Symfony\\Component\\VarDumper\\Cloner\\VarCloner::setMaxItems`
27+
configures the maximum number of items that will be cloned *past the first
28+
nesting level*. Items are counted using a breadth-first algorithm so that
29+
lower level items have higher priority than deeply nested items;
30+
* :method:`Symfony\\Component\\VarDumper\\Cloner\\VarCloner::setMaxString`
31+
configures the maximum number of characters that will be cloned before
32+
cutting overlong strings;
33+
* in both cases, specifying `-1` removes any limit.
2934

3035
Before dumping it, you can further limit the resulting
3136
:class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object by calling its
@@ -34,16 +39,16 @@ method:
3439

3540
* the first ``$maxDepth`` argument allows limiting dumps in the depth dimension,
3641
* the second ``$maxItemsPerDepth`` limits the number of items per depth level,
37-
* and the last ``$useRefHandles`` defaults to ``true`` but allows removing internal
38-
objects' handles for sparser output,
39-
* but unlike the previous limits on cloners that remove data on purpose, these
40-
limits can be changed back and forth before dumping since they do not affect
42+
* and the last ``$useRefHandles`` defaults to ``true`` but allows removing
43+
internal objects' handles for sparser output,
44+
* but unlike the previous limits on cloners that remove data on purpose,
45+
these can be changed back and forth before dumping since they do not affect
4146
the intermediate representation internally.
4247

4348
.. note::
4449
When no limit is applied, a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data`
45-
object is as accurate as the native :phpfunction:`serialize` function and thus
46-
could have a wider purpose than strictly dumping for debugging.
50+
object is as accurate as the native :phpfunction:`serialize` function
51+
and thus could have a wider purpose than strictly dumping for debugging.
4752

4853
Dumpers
4954
~~~~~~~

0 commit comments

Comments
 (0)