From 7b26e4482011cc00c455e99fc297b32b49fb2f51 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sat, 3 Dec 2016 14:07:55 +0100 Subject: [PATCH 1/9] Document new environment variables and display options --- components/var_dumper/advanced.rst | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index fc5708955c8..168df427c18 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -97,7 +97,12 @@ Dumpers A dumper is responsible for outputting a string representation of a PHP variable, using a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object as input. -The destination and the formatting of this output vary with dumpers. +The destination and the formatting of this output vary with dumpers and are +influenced by two environment variables: +If ``DUMP_STRING_LENGTH`` is set, then +the length of a string is displayed next to its content. +If ``DUMP_LIGHT_ARRAY`` is set, +then arrays are not displayed completely. This component comes with an :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` for HTML output and a :class:`Symfony\\Component\\VarDumper\\Dumper\\CliDumper` @@ -181,6 +186,21 @@ method. They also typically implement the them from re-implementing the logic required to walk through a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object's internal structure. +The HTMLDumper limits string length and nesting depth of the output. +These options can be overriden by providing a third parameter when calling ``dump``:: + + use Symfony\Component\VarDumper\Dumper\HtmlDumper; + + $output = fopen('php://memory', 'r+b'); + + $dumper = new HtmlDumper(); + $dumper->dump($var, $output, array( + 'maxDepth' => 1, + 'maxStringLength' => 160 + )); + + // Limit nesting to 1 level and string length to 160 characters (default) + Casters ------- From adbec6d973d4d8e25e1fd7a1d3bfb8dd41bc728c Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sat, 3 Dec 2016 15:23:47 +0100 Subject: [PATCH 2/9] Reformat documentation and link to class doc. --- components/var_dumper/advanced.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index 168df427c18..7100ece7d88 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -99,10 +99,9 @@ A dumper is responsible for outputting a string representation of a PHP variable using a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object as input. The destination and the formatting of this output vary with dumpers and are influenced by two environment variables: -If ``DUMP_STRING_LENGTH`` is set, then -the length of a string is displayed next to its content. -If ``DUMP_LIGHT_ARRAY`` is set, -then arrays are not displayed completely. + +- If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed next to its content. +- If ``DUMP_LIGHT_ARRAY`` is set, then arrays are not displayed completely. This component comes with an :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` for HTML output and a :class:`Symfony\\Component\\VarDumper\\Dumper\\CliDumper` @@ -186,7 +185,7 @@ method. They also typically implement the them from re-implementing the logic required to walk through a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object's internal structure. -The HTMLDumper limits string length and nesting depth of the output. +The :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` limits string length and nesting depth of the output. These options can be overriden by providing a third parameter when calling ``dump``:: use Symfony\Component\VarDumper\Dumper\HtmlDumper; From 934084607ee9d10ea0f9deb26d42b21d6a6ddb4c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 3 Dec 2016 16:16:27 +0100 Subject: [PATCH 3/9] Replaced the list to use an unordered list --- components/var_dumper/advanced.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index 7100ece7d88..0eed58664bf 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -100,8 +100,8 @@ using a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object as input. The destination and the formatting of this output vary with dumpers and are influenced by two environment variables: -- If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed next to its content. -- If ``DUMP_LIGHT_ARRAY`` is set, then arrays are not displayed completely. +* If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed next to its content. +* If ``DUMP_LIGHT_ARRAY`` is set, then arrays are not displayed completely. This component comes with an :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` for HTML output and a :class:`Symfony\\Component\\VarDumper\\Dumper\\CliDumper` From dfb6d6ae2f330dd676b73bb28a9847dda28550dd Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 3 Dec 2016 16:17:35 +0100 Subject: [PATCH 4/9] Trimmed some lines to respect the 80-char soft limit --- components/var_dumper/advanced.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index 0eed58664bf..5b1454f8378 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -100,7 +100,8 @@ using a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object as input. The destination and the formatting of this output vary with dumpers and are influenced by two environment variables: -* If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed next to its content. +* If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed + next to its content. * If ``DUMP_LIGHT_ARRAY`` is set, then arrays are not displayed completely. This component comes with an :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` @@ -185,8 +186,9 @@ method. They also typically implement the them from re-implementing the logic required to walk through a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object's internal structure. -The :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` limits string length and nesting depth of the output. -These options can be overriden by providing a third parameter when calling ``dump``:: +The :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` limits string +length and nesting depth of the output. These options can be overriden by +providing a third parameter when calling ``dump``:: use Symfony\Component\VarDumper\Dumper\HtmlDumper; From ad90321659487bbdcbbad430f778d0b989dbfb2a Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sat, 3 Dec 2016 18:09:21 +0100 Subject: [PATCH 5/9] Describe flags in more detail --- components/var_dumper/advanced.rst | 75 +++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index 5b1454f8378..0e67c0bc7b3 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -97,12 +97,7 @@ Dumpers A dumper is responsible for outputting a string representation of a PHP variable, using a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object as input. -The destination and the formatting of this output vary with dumpers and are -influenced by two environment variables: - -* If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed - next to its content. -* If ``DUMP_LIGHT_ARRAY`` is set, then arrays are not displayed completely. +The destination and the formatting of this output vary with dumpers. This component comes with an :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` for HTML output and a :class:`Symfony\\Component\\VarDumper\\Dumper\\CliDumper` @@ -202,6 +197,74 @@ providing a third parameter when calling ``dump``:: // Limit nesting to 1 level and string length to 160 characters (default) +The output format of a dumper can be fine tuned by the two flags ``DUMP_STRING_LENGTH`` +and ``DUMP_LIGHT_ARRAY`` which are passed as a bitmap in the third constructor argument. +They can also be set via environment variables when using ``assertDumpEquals`` of the +:class:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait` during unit testing. +The flags can be configured in :file:`phpunit.xml.dist`. + +* If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed + next to its content. + +:: + + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; + + $var = array('test'); + $dumper = new CliDumper(); + echo $dumper->dump($var, true); + + // array:1 [ + // 0 => "test" + // ] + + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH); + echo $dumper->dump($var, true); + + // (added string length before the string) + // array:1 [ + // 0 => (4) "test" + // ] + +* If ``DUMP_LIGHT_ARRAY`` is set, then arrays are dumped in a shortened format. + +:: + + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; + + $var = array('test'); + $dumper = new CliDumper(); + echo $dumper->dump($var, true); + + // array:1 [ + // 0 => "test" + // ] + + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY); + echo $dumper->dump($var, true); + + // (no more array:1 prefix) + // [ + // 0 => "test" + // ] + +* If you would like to use both options, then you can just combine them by using a the logical OR operator ``|``. + +:: + + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; + + $var = array('test'); + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH | AbstractDumper::DUMP_LIGHT_ARRAY); + echo $dumper->dump($var, true); + + // [ + // 0 => (4) "test" + // ] + Casters ------- From 6b2248e9a94055039dda350adf4584d64d71b569 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sat, 3 Dec 2016 18:11:33 +0100 Subject: [PATCH 6/9] Fix mention of file --- components/var_dumper/advanced.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index 0e67c0bc7b3..7c7f9d830b9 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -201,7 +201,7 @@ The output format of a dumper can be fine tuned by the two flags ``DUMP_STRING_L and ``DUMP_LIGHT_ARRAY`` which are passed as a bitmap in the third constructor argument. They can also be set via environment variables when using ``assertDumpEquals`` of the :class:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait` during unit testing. -The flags can be configured in :file:`phpunit.xml.dist`. +The flags can be configured in ``phpunit.xml.dist``. * If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed next to its content. From 0c46fce3215f0ee2c44222343eb8ad8950ab031c Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sat, 3 Dec 2016 18:19:35 +0100 Subject: [PATCH 7/9] Respect 80 chars line length --- components/var_dumper/advanced.rst | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index 7c7f9d830b9..e68af47508c 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -183,7 +183,9 @@ them from re-implementing the logic required to walk through a The :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` limits string length and nesting depth of the output. These options can be overriden by -providing a third parameter when calling ``dump``:: +providing a third parameter when calling +:method:`dump(Data $data) ` +:: use Symfony\Component\VarDumper\Dumper\HtmlDumper; @@ -197,11 +199,12 @@ providing a third parameter when calling ``dump``:: // Limit nesting to 1 level and string length to 160 characters (default) -The output format of a dumper can be fine tuned by the two flags ``DUMP_STRING_LENGTH`` -and ``DUMP_LIGHT_ARRAY`` which are passed as a bitmap in the third constructor argument. -They can also be set via environment variables when using ``assertDumpEquals`` of the -:class:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait` during unit testing. -The flags can be configured in ``phpunit.xml.dist``. +The output format of a dumper can be fine tuned by the two flags +``DUMP_STRING_LENGTH`` and ``DUMP_LIGHT_ARRAY`` which are passed as a bitmap +in the third constructor argument. They can also be set via environment +variables when using +:method:`assertDumpEquals($dump, $data, $message) ` +during unit testing. The flags can be configured in ``phpunit.xml.dist``. * If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed next to its content. @@ -250,7 +253,8 @@ The flags can be configured in ``phpunit.xml.dist``. // 0 => "test" // ] -* If you would like to use both options, then you can just combine them by using a the logical OR operator ``|``. +* If you would like to use both options, then you can just + combine them by using a the logical OR operator ``|``. :: From 2ef1b60f1731739c1ecaf6cd7d5b6b8401f65466 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Thu, 8 Dec 2016 20:37:40 +0100 Subject: [PATCH 8/9] Fix format --- components/var_dumper/advanced.rst | 85 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index e68af47508c..a2867b68011 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -97,7 +97,7 @@ Dumpers A dumper is responsible for outputting a string representation of a PHP variable, using a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object as input. -The destination and the formatting of this output vary with dumpers. +The destination and the formatting of this output vary with dumpers. This component comes with an :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` for HTML output and a :class:`Symfony\\Component\\VarDumper\\Dumper\\CliDumper` @@ -204,70 +204,71 @@ The output format of a dumper can be fine tuned by the two flags in the third constructor argument. They can also be set via environment variables when using :method:`assertDumpEquals($dump, $data, $message) ` -during unit testing. The flags can be configured in ``phpunit.xml.dist``. +during unit testing. The flags can be configured in the PHPUnit configuration. * If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed next to its content. -:: + .. code-block:: php - use Symfony\Component\VarDumper\Dumper\AbstractDumper; - use Symfony\Component\VarDumper\Dumper\CliDumper; + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; - $var = array('test'); - $dumper = new CliDumper(); - echo $dumper->dump($var, true); + $var = array('test'); + $dumper = new CliDumper(); + echo $dumper->dump($var, true); - // array:1 [ - // 0 => "test" - // ] + // array:1 [ + // 0 => "test" + // ] - $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH); - echo $dumper->dump($var, true); + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH); + echo $dumper->dump($var, true); - // (added string length before the string) - // array:1 [ - // 0 => (4) "test" - // ] + // (added string length before the string) + // array:1 [ + // 0 => (4) "test" + // ] -* If ``DUMP_LIGHT_ARRAY`` is set, then arrays are dumped in a shortened format. +* If ``DUMP_LIGHT_ARRAY`` is set, then arrays are dumped in a shortened format + similar to PHP's short array notation. -:: + .. code-block:: php - use Symfony\Component\VarDumper\Dumper\AbstractDumper; - use Symfony\Component\VarDumper\Dumper\CliDumper; + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; - $var = array('test'); - $dumper = new CliDumper(); - echo $dumper->dump($var, true); + $var = array('test'); + $dumper = new CliDumper(); + echo $dumper->dump($var, true); - // array:1 [ - // 0 => "test" - // ] + // array:1 [ + // 0 => "test" + // ] - $dumper = new CliDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY); - echo $dumper->dump($var, true); + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY); + echo $dumper->dump($var, true); - // (no more array:1 prefix) - // [ - // 0 => "test" - // ] + // (no more array:1 prefix) + // [ + // 0 => "test" + // ] * If you would like to use both options, then you can just combine them by using a the logical OR operator ``|``. -:: + .. code-block:: php - use Symfony\Component\VarDumper\Dumper\AbstractDumper; - use Symfony\Component\VarDumper\Dumper\CliDumper; + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; - $var = array('test'); - $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH | AbstractDumper::DUMP_LIGHT_ARRAY); - echo $dumper->dump($var, true); + $var = array('test'); + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH | AbstractDumper::DUMP_LIGHT_ARRAY); + echo $dumper->dump($var, true); - // [ - // 0 => (4) "test" - // ] + // [ + // 0 => (4) "test" + // ] Casters ------- From 29080a6814567c4daf1eedd9b306491b747aa946 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 15 Apr 2017 15:27:34 +0200 Subject: [PATCH 9/9] Minor formatting changes --- components/var_dumper/advanced.rst | 101 ++++++++++++++--------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index a2867b68011..e61e381b460 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -182,10 +182,10 @@ them from re-implementing the logic required to walk through a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object's internal structure. The :class:`Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper` limits string -length and nesting depth of the output. These options can be overriden by -providing a third parameter when calling +length and nesting depth of the output to make it more readable. These options +can be overriden by the third optional parameter of the :method:`dump(Data $data) ` -:: +method:: use Symfony\Component\VarDumper\Dumper\HtmlDumper; @@ -193,82 +193,81 @@ providing a third parameter when calling $dumper = new HtmlDumper(); $dumper->dump($var, $output, array( + // 1 and 160 are the default values for these options 'maxDepth' => 1, 'maxStringLength' => 160 )); - // Limit nesting to 1 level and string length to 160 characters (default) - The output format of a dumper can be fine tuned by the two flags ``DUMP_STRING_LENGTH`` and ``DUMP_LIGHT_ARRAY`` which are passed as a bitmap in the third constructor argument. They can also be set via environment variables when using :method:`assertDumpEquals($dump, $data, $message) ` -during unit testing. The flags can be configured in the PHPUnit configuration. +during unit testing. -* If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed - next to its content. +If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed +next to its content: - .. code-block:: php +.. code-block:: php - use Symfony\Component\VarDumper\Dumper\AbstractDumper; - use Symfony\Component\VarDumper\Dumper\CliDumper; + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; - $var = array('test'); - $dumper = new CliDumper(); - echo $dumper->dump($var, true); + $var = array('test'); + $dumper = new CliDumper(); + echo $dumper->dump($var, true); - // array:1 [ - // 0 => "test" - // ] + // array:1 [ + // 0 => "test" + // ] - $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH); - echo $dumper->dump($var, true); + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH); + echo $dumper->dump($var, true); - // (added string length before the string) - // array:1 [ - // 0 => (4) "test" - // ] + // (added string length before the string) + // array:1 [ + // 0 => (4) "test" + // ] -* If ``DUMP_LIGHT_ARRAY`` is set, then arrays are dumped in a shortened format - similar to PHP's short array notation. +If ``DUMP_LIGHT_ARRAY`` is set, then arrays are dumped in a shortened format +similar to PHP's short array notation: - .. code-block:: php +.. code-block:: php - use Symfony\Component\VarDumper\Dumper\AbstractDumper; - use Symfony\Component\VarDumper\Dumper\CliDumper; + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; - $var = array('test'); - $dumper = new CliDumper(); - echo $dumper->dump($var, true); + $var = array('test'); + $dumper = new CliDumper(); + echo $dumper->dump($var, true); - // array:1 [ - // 0 => "test" - // ] + // array:1 [ + // 0 => "test" + // ] - $dumper = new CliDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY); - echo $dumper->dump($var, true); + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY); + echo $dumper->dump($var, true); - // (no more array:1 prefix) - // [ - // 0 => "test" - // ] + // (no more array:1 prefix) + // [ + // 0 => "test" + // ] -* If you would like to use both options, then you can just - combine them by using a the logical OR operator ``|``. +If you would like to use both options, then you can just combine them by +using a the logical OR operator ``|``: - .. code-block:: php +.. code-block:: php - use Symfony\Component\VarDumper\Dumper\AbstractDumper; - use Symfony\Component\VarDumper\Dumper\CliDumper; + use Symfony\Component\VarDumper\Dumper\AbstractDumper; + use Symfony\Component\VarDumper\Dumper\CliDumper; - $var = array('test'); - $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH | AbstractDumper::DUMP_LIGHT_ARRAY); - echo $dumper->dump($var, true); + $var = array('test'); + $dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH | AbstractDumper::DUMP_LIGHT_ARRAY); + echo $dumper->dump($var, true); - // [ - // 0 => (4) "test" - // ] + // [ + // 0 => (4) "test" + // ] Casters -------