Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2462c5b

Browse filesBrowse files
[VarDumper] with-er interface for Cloner\Data
1 parent ce8d371 commit 2462c5b
Copy full SHA for 2462c5b

File tree

Expand file treeCollapse file tree

3 files changed

+56
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+56
-2
lines changed

‎src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,12 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
168168
$dumps = array();
169169

170170
foreach ($this->data as $dump) {
171-
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
171+
if (method_exists($dump['data'], 'withMaxDepth')) {
172+
$dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth));
173+
} else {
174+
// getLimitedClone is @deprecated, to be removed in 3.0
175+
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
176+
}
172177
rewind($data);
173178
$dump['data'] = stream_get_contents($data);
174179
ftruncate($data, 0);

‎src/Symfony/Component/VarDumper/Cloner/Data.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/Data.php
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,51 @@ public function getRawData()
3737
return $this->data;
3838
}
3939

40+
/**
41+
* Returns a depth limited clone of $this.
42+
*
43+
* @param int $maxDepth The max dumped depth level.
44+
*
45+
* @return self A clone of $this.
46+
*/
47+
public function withMaxDepth($maxDepth)
48+
{
49+
$data = clone $this;
50+
$data->maxDepth = (int) $maxDepth;
51+
52+
return $data;
53+
}
54+
55+
/**
56+
* Limits the numbers of elements per depth level.
57+
*
58+
* @param int $maxItemsPerDepth The max number of items dumped per depth level.
59+
*
60+
* @return self A clone of $this.
61+
*/
62+
public function withMaxItemsPerDepth($maxItemsPerDepth)
63+
{
64+
$data = clone $this;
65+
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;
66+
67+
return $data;
68+
}
69+
70+
/**
71+
* Enables/disables objects' identifiers tracking.
72+
*
73+
* @param bool $useRefHandles False to hide global ref. handles.
74+
*
75+
* @return self A clone of $this.
76+
*/
77+
public function withRefHandles($useRefHandles)
78+
{
79+
$data = clone $this;
80+
$data->useRefHandles = $useRefHandles ? -1 : 0;
81+
82+
return $data;
83+
}
84+
4085
/**
4186
* Returns a depth limited clone of $this.
4287
*
@@ -45,9 +90,13 @@ public function getRawData()
4590
* @param bool $useRefHandles False to hide ref. handles.
4691
*
4792
* @return self A depth limited clone of $this.
93+
*
94+
* @deprecated since Symfony 2.7, to be removed in 3.0. Use withMaxDepth, withMaxItemsPerDepth or withRefHandles instead.
4895
*/
4996
public function getLimitedClone($maxDepth, $maxItemsPerDepth, $useRefHandles = true)
5097
{
98+
trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0. Use withMaxDepth, withMaxItemsPerDepth or withRefHandles methods instead.', E_USER_DEPRECATED);
99+
51100
$data = clone $this;
52101
$data->maxDepth = (int) $maxDepth;
53102
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;

‎src/Symfony/Component/VarDumper/Tests/CliDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function testBuggyRefs()
211211
$dumper->setColors(false);
212212
$cloner = new VarCloner();
213213

214-
$data = $cloner->cloneVar($var)->getLimitedClone(3, -1);
214+
$data = $cloner->cloneVar($var)->withMaxDepth(3);
215215
$out = '';
216216
$dumper->dump($data, function ($line, $depth) use (&$out) {
217217
if ($depth >= 0) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.