Skip to content

Commit 9fcc57f

Browse files
committed
IHF: get_dump function added.
1 parent b38d58e commit 9fcc57f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/dump.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
use Symfony\Component\VarDumper\Cloner\VarCloner;
4+
use Symfony\Component\VarDumper\Dumper\CliDumper;
5+
6+
if (!function_exists('get_dump')) {
7+
function get_dump($var)
8+
{
9+
$cloner = new VarCloner();
10+
$cloner->setMaxItems(-1);
11+
$cloner->setMaxString(-1);
12+
13+
$cloned = $cloner->cloneVar($var);
14+
$cloned->withMaxDepth(-1);
15+
$cloned->withMaxItemsPerDepth(-1);
16+
$cloned->withRefHandles(-1);
17+
18+
$dumper = new CliDumper();
19+
$dumper->setIndentPad(' ');
20+
$output = fopen('php://memory', 'r+b');
21+
$dumper->dump($cloned, $output);
22+
23+
return stream_get_contents($output, -1, 0);
24+
}
25+
}

0 commit comments

Comments
 (0)