Skip to content

Commit b5b99f4

Browse files
committed
bug #12232 Fix some examples (makmaoui)
This PR was submitted for the 4.3 branch but it was squashed and merged into the 3.4 branch instead (closes #12232). Discussion ---------- Fix some examples The dumper requires a Cloner\Data object instead of the original variables <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- aecc29a Fix some examples
2 parents cb730c4 + aecc29a commit b5b99f4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Diff for: components/var_dumper/advanced.rst

+14-5
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,22 @@ output produced by the different casters.
237237
If ``DUMP_STRING_LENGTH`` is set, then the length of a string is displayed
238238
next to its content::
239239

240+
use Symfony\Component\VarDumper\Cloner\VarCloner;
240241
use Symfony\Component\VarDumper\Dumper\AbstractDumper;
241242
use Symfony\Component\VarDumper\Dumper\CliDumper;
242243

244+
$varCloner = new VarCloner();
243245
$var = ['test'];
246+
244247
$dumper = new CliDumper();
245-
echo $dumper->dump($var, true);
248+
echo $dumper->dump($varCloner->cloneVar($var), true);
246249

247250
// array:1 [
248251
// 0 => "test"
249252
// ]
250253

251254
$dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH);
252-
echo $dumper->dump($var, true);
255+
echo $dumper->dump($varCloner->cloneVar($var), true);
253256

254257
// (added string length before the string)
255258
// array:1 [
@@ -259,19 +262,22 @@ next to its content::
259262
If ``DUMP_LIGHT_ARRAY`` is set, then arrays are dumped in a shortened format
260263
similar to PHP's short array notation::
261264

265+
use Symfony\Component\VarDumper\Cloner\VarCloner;
262266
use Symfony\Component\VarDumper\Dumper\AbstractDumper;
263267
use Symfony\Component\VarDumper\Dumper\CliDumper;
264268

269+
$varCloner = new VarCloner();
265270
$var = ['test'];
271+
266272
$dumper = new CliDumper();
267-
echo $dumper->dump($var, true);
273+
echo $dumper->dump($varCloner->cloneVar($var), true);
268274

269275
// array:1 [
270276
// 0 => "test"
271277
// ]
272278

273279
$dumper = new CliDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY);
274-
echo $dumper->dump($var, true);
280+
echo $dumper->dump($varCloner->cloneVar($var), true);
275281

276282
// (no more array:1 prefix)
277283
// [
@@ -281,12 +287,15 @@ similar to PHP's short array notation::
281287
If you would like to use both options, then you can just combine them by
282288
using the logical OR operator ``|``::
283289

290+
use Symfony\Component\VarDumper\Cloner\VarCloner;
284291
use Symfony\Component\VarDumper\Dumper\AbstractDumper;
285292
use Symfony\Component\VarDumper\Dumper\CliDumper;
286293

294+
$varCloner = new VarCloner();
287295
$var = ['test'];
296+
288297
$dumper = new CliDumper(null, null, AbstractDumper::DUMP_STRING_LENGTH | AbstractDumper::DUMP_LIGHT_ARRAY);
289-
echo $dumper->dump($var, true);
298+
echo $dumper->dump($varCloner->cloneVar($var), true);
290299

291300
// [
292301
// 0 => (4) "test"

0 commit comments

Comments
 (0)