8000 Merge branch '2.6' into 2.7 · symfony/symfony@045433c · GitHub
[go: up one dir, main page]

Skip to content

Commit 045433c

Browse files
Merge branch '2.6' into 2.7
* 2.6: [VarDumper] Towards PHP7 support Conflicts: src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php src/Symfony/Component/VarDumper/Tests/CliDumperTest.php src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
2 parents af548e4 + 8054629 commit 045433c

File tree

5 files changed

+25
-28
lines changed

5 files changed

+25
-28
lines changed

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,28 @@ class ExceptionCaster
4242

4343
public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0)
4444
{
45-
$trace = $a["\0Exception\0trace"];
46-
unset($a["\0Exception\0trace"]); // Ensures the trace is always last
45+
$xPrefix = PHP_VERSION_ID >= 70000 ? "\0BaseException\0" : "\0Exception\0";
46+
$trace = $a[$xPrefix.'trace'];
47+
unset($a[$xPrefix.'trace']); // Ensures the trace is always last
4748

4849
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
4950
static::filterTrace($trace, static::$traceArgs);
5051

5152
if (null !== $trace) {
52-
$a["\0Exception\0trace"] = $trace;
53+
$a[$xPrefix.'trace'] = $trace;
5354
}
5455
}
55-
if (empty($a["\0Exception\0previous"])) {
56-
unset($a["\0Exception\0previous"]);
56+
if (empty($a[$xPrefix.'previous'])) {
57+
unset($a[$xPrefix.'previous']);
5758
}
58-
unset($a["\0Exception\0string"], $a["\0+\0xdebug_message"], $a["\0+\0__destructorException"]);
59+
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
5960

6061
return $a;
6162
}
6263

6364
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
6465
{
65-
if (isset($a[$s = "\0*\0severity"], self::$errorTypes[$a[$s]])) {
66+
if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) {
6667
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
6768
}
6869

@@ -71,23 +72,21 @@ public static function castErrorException(\ErrorException $e, array $a, Stub $st
7172

7273
public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, $isNested)
7374
{
74-
$b = (array) $a["\0Exception\0previous"];
75-
76-
if (isset($b["\0*\0message"])) {
77-
$a["\0~\0message"] = $b["\0*\0message"];
78-
}
79-
80-
if (isset($a["\0Exception\0trace"])) {
81-
$b["\0Exception\0trace"][0] += array(
82-
'file' => $b["\0*\0file"],
83-
'line' => $b["\0*\0line"],
75+
$prefix = Caster::PREFIX_PROTECTED;
76+
$xPrefix = PHP_VERSION_ID >= 70000 ? "\0BaseException\0" : "\0Exception\0";
77+
$b = (array) $a[$xPrefix.'previous'];
78+
79+
if (isset($a[$xPrefix.'trace'][0])) {
80+
$b[$xPrefix.'trace'][0] += array(
81+
'file' => $b[$prefix.'file'],
82+
'line' => $b[$prefix.'line'],
8483
);
85-
array_splice($b["\0Exception\0trace"], -1 - count($a["\0Exception\0trace"]));
86-
static::filterTrace($b["\0Exception\0trace"], false);
87-
$a["\0~\0trace"] = $b["\0Exception\0trace"];
84+
array_splice($b[$xPrefix.'trace'], -1 - count($a[$xPrefix.'trace']));
85+
static::filterTrace($b[$xPrefix.'trace'], false);
86+
$a[Caster::PREFIX_VIRTUAL.'trace'] = $b[$xPrefix.'trace'];
8887
}
8988

90-
unset($a["\0Exception\0trace"], $a["\0Exception\0previous"], $a["\0*\0code"], $a["\0*\0file"], $a["\0*\0line"]);
89+
unset($a[$xPrefix.'trace'], $a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
9190

9291
return $a;
9392
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,10 @@ protected function doClone($var)
119119
$stub = $arrayRefs[$len] = new Stub();
120120
$stub->type = Stub::TYPE_ARRAY;
121121
$stub->class = Stub::ARRAY_ASSOC;
122-
$stub->value = $zval['array_count'] ?: count($v);
123-
124-
$a = $v;
125122

126123
// Copies of $GLOBALS have very strange behavior,
127124
// let's detect them with some black magic
125+
$a = $v;
128126
$a[$gid] = true;
129127

130128
// Happens with copies of $GLOBALS
@@ -137,6 +135,8 @@ protected function doClone($var)
137135
} else {
138136
$a = $v;
139137
}
138+
139+
$stub->value = $zval['array_count'] ?: count($a);
140140
}
141141
break;
142142

src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ class ThrowingCasterException extends \Exception
2222
*/
2323
public function __construct($caster, \Exception $prev)
2424
{
25-
parent::__construct('Unexpected exception thrown from a caster: '.get_class($prev), 0, $prev);
25+
parent::__construct('Unexpected '.get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev);
2626
}
2727
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ public function testThrowingCaster()
173173
eof: false
174174
options: []
175175
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {#%d
176-
#message: "Unexpected exception thrown from a caster: Exception"
177-
message: "Foobar"
176+
#message: "Unexpected Exception thrown from a caster: Foobar"
178177
trace: array:1 [
179178
0 => array:2 [
180179
"call" => "%s{closure}()"

src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function testGet()
3939
ob_start();
4040
$dumper->dump($data);
4141
$out = ob_get_clean();
42-
$closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function';
4342
$out = preg_replace('/[ \t]+$/m', '', $out);
4443
$var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8');
4544
$intMax = PHP_INT_MAX;

0 commit comments

Comments
 (0)
0