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 7937ad0

Browse filesBrowse files
[VarDumper] Dont use empty(), it chokes on eg GMP objects
1 parent 0d433cd commit 7937ad0
Copy full SHA for 7937ad0

File tree

2 files changed

+10
-4
lines changed
Filter options

2 files changed

+10
-4
lines changed

‎src/Symfony/Component/VarDumper/Caster/Caster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/Caster.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ public static function filter(array $a, $filter, array $listedProperties = array
118118

119119
if (null === $v) {
120120
$type |= self::EXCLUDE_NULL & $filter;
121-
}
122-
if (empty($v)) {
121+
$type |= self::EXCLUDE_EMPTY & $filter;
122+
} elseif (false === $v || '' === $v || '0' === $v || 0 === $v || 0.0 === $v || array() === $v) {
123123
$type |= self::EXCLUDE_EMPTY & $filter;
124124
}
125125
if ((self::EXCLUDE_NOT_IMPORTANT & $filter) && !in_array($k, $listedProperties, true)) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/VarCloner.php
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ protected function doClone($var)
9494
// Create $stub when the original value $v can not be used directly
9595
// If $v is a nested structure, put that structure in array $a
9696
switch (true) {
97-
case empty($v):
98-
case true === $v:
97+
case \is_null($v):
98+
case \is_bool($v):
9999
case \is_int($v):
100100
case \is_float($v):
101101
continue 2;
102102

103103
case \is_string($v):
104+
if ('' === $v) {
105+
continue 2;
106+
}
104107
if (!\preg_match('//u', $v)) {
105108
$stub = new Stub();
106109
$stub->type = Stub::TYPE_STRING;
@@ -124,6 +127,9 @@ protected function doClone($var)
124127
break;
125128

126129
case \is_array($v):
130+
if (!$v) {
131+
continue 2;
132+
}
127133
$stub = $arrayStub;
128134
$stub->class = Stub::ARRAY_INDEXED;
129135

0 commit comments

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