8000 [VarDumper] Dont use empty(), it chokes on eg GMP objects · symfony/symfony@1b14173 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b14173

Browse files
[VarDumper] Dont use empty(), it chokes on eg GMP objects
1 parent 0d433cd commit 1b14173

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

Lines 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

Lines 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 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