Skip to content

Commit 842479a

Browse files
nicolas-grekasfabpot
authored andcommitted
[TwigBundle/DebugBundle] move dump extension & cleanups
1 parent dd32e7f commit 842479a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

DataCollector/DumpDataCollector.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,21 @@ public function getDumpsCount()
155155

156156
public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
157157
{
158+
$data = fopen('php://memory' 'r+b');
159+
158160
if ('html' === $format) {
159-
$dumper = new HtmlDumper();
161+
$dumper = new HtmlDumper($data);
160162
} else {
161163
throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format));
162164
}
163165
$dumps = array();
164166

165167
foreach ($this->data as $dump) {
166-
$data = '';
167-
$dumper->dump(
168-
$dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth),
169-
function ($line, $depth) use (&$data) {
170-
if (-1 !== $depth) {
171-
$data .= str_repeat(' ', $depth).$line."\n";
172-
}
173-
}
174-
);
175-
$dump['data'] = $data;
168+
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
169+
rewind($data);
170+
$dump['data'] = stream_get_contents($data);
171+
ftruncate($data, 0);
172+
rewind($data);
176173
$dumps[] = $dump;
177174
}
178175

0 commit comments

Comments
 (0)