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
This commit is contained in:
commit
045433c7c4
@ -42,27 +42,28 @@ class ExceptionCaster
|
|||||||
|
|
||||||
public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0)
|
public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0)
|
||||||
{
|
{
|
||||||
$trace = $a["\0Exception\0trace"];
|
$xPrefix = PHP_VERSION_ID >= 70000 ? "\0BaseException\0" : "\0Exception\0";
|
||||||
unset($a["\0Exception\0trace"]); // Ensures the trace is always last
|
$trace = $a[$xPrefix.'trace'];
|
||||||
|
unset($a[$xPrefix.'trace']); // Ensures the trace is always last
|
||||||
|
|
||||||
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||||
static::filterTrace($trace, static::$traceArgs);
|
static::filterTrace($trace, static::$traceArgs);
|
||||||
|
|
||||||
if (null !== $trace) {
|
if (null !== $trace) {
|
||||||
$a["\0Exception\0trace"] = $trace;
|
$a[$xPrefix.'trace'] = $trace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($a["\0Exception\0previous"])) {
|
if (empty($a[$xPrefix.'previous'])) {
|
||||||
unset($a["\0Exception\0previous"]);
|
unset($a[$xPrefix.'previous']);
|
||||||
}
|
}
|
||||||
unset($a["\0Exception\0string"], $a["\0+\0xdebug_message"], $a["\0+\0__destructorException"]);
|
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
|
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
|
||||||
{
|
{
|
||||||
if (isset($a[$s = "\0*\0severity"], self::$errorTypes[$a[$s]])) {
|
if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) {
|
||||||
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
|
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,23 +72,21 @@ class ExceptionCaster
|
|||||||
|
|
||||||
public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, $isNested)
|
public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, $isNested)
|
||||||
{
|
{
|
||||||
$b = (array) $a["\0Exception\0previous"];
|
$prefix = Caster::PREFIX_PROTECTED;
|
||||||
|
$xPrefix = PHP_VERSION_ID >= 70000 ? "\0BaseException\0" : "\0Exception\0";
|
||||||
|
$b = (array) $a[$xPrefix.'previous'];
|
||||||
|
|
||||||
if (isset($b["\0*\0message"])) {
|
if (isset($a[$xPrefix.'trace'][0])) {
|
||||||
$a["\0~\0message"] = $b["\0*\0message"];
|
$b[$xPrefix.'trace'][0] += array(
|
||||||
}
|
'file' => $b[$prefix.'file'],
|
||||||
|
'line' => $b[$prefix.'line'],
|
||||||
if (isset($a["\0Exception\0trace"])) {
|
|
||||||
$b["\0Exception\0trace"][0] += array(
|
|
||||||
'file' => $b["\0*\0file"],
|
|
||||||
'line' => $b["\0*\0line"],
|
|
||||||
);
|
);
|
||||||
array_splice($b["\0Exception\0trace"], -1 - count($a["\0Exception\0trace"]));
|
array_splice($b[$xPrefix.'trace'], -1 - count($a[$xPrefix.'trace']));
|
||||||
static::filterTrace($b["\0Exception\0trace"], false);
|
static::filterTrace($b[$xPrefix.'trace'], false);
|
||||||
$a["\0~\0trace"] = $b["\0Exception\0trace"];
|
$a[Caster::PREFIX_VIRTUAL.'trace'] = $b[$xPrefix.'trace'];
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($a["\0Exception\0trace"], $a["\0Exception\0previous"], $a["\0*\0code"], $a["\0*\0file"], $a["\0*\0line"]);
|
unset($a[$xPrefix.'trace'], $a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,10 @@ class VarCloner extends AbstractCloner
|
|||||||
$stub = $arrayRefs[$len] = new Stub();
|
$stub = $arrayRefs[$len] = new Stub();
|
||||||
$stub->type = Stub::TYPE_ARRAY;
|
$stub->type = Stub::TYPE_ARRAY;
|
||||||
$stub->class = Stub::ARRAY_ASSOC;
|
$stub->class = Stub::ARRAY_ASSOC;
|
||||||
$stub->value = $zval['array_count'] ?: count($v);
|
|
||||||
|
|
||||||
$a = $v;
|
|
||||||
|
|
||||||
// Copies of $GLOBALS have very strange behavior,
|
// Copies of $GLOBALS have very strange behavior,
|
||||||
// let's detect them with some black magic
|
// let's detect them with some black magic
|
||||||
|
$a = $v;
|
||||||
$a[$gid] = true;
|
$a[$gid] = true;
|
||||||
|
|
||||||
// Happens with copies of $GLOBALS
|
// Happens with copies of $GLOBALS
|
||||||
@ -137,6 +135,8 @@ class VarCloner extends AbstractCloner
|
|||||||
} else {
|
} else {
|
||||||
$a = $v;
|
$a = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$stub->value = $zval['array_count'] ?: count($a);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -22,6 +22,6 @@ class ThrowingCasterException extends \Exception
|
|||||||
*/
|
*/
|
||||||
public function __construct($caster, \Exception $prev)
|
public function __construct($caster, \Exception $prev)
|
||||||
{
|
{
|
||||||
parent::__construct('Unexpected exception thrown from a caster: '.get_class($prev), 0, $prev);
|
parent::__construct('Unexpected '.get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,7 @@ EOTXT
|
|||||||
eof: false
|
eof: false
|
||||||
options: []
|
options: []
|
||||||
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {#%d
|
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {#%d
|
||||||
#message: "Unexpected exception thrown from a caster: Exception"
|
#message: "Unexpected Exception thrown from a caster: Foobar"
|
||||||
message: "Foobar"
|
|
||||||
trace: array:1 [
|
trace: array:1 [
|
||||||
0 => array:2 [
|
0 => array:2 [
|
||||||
"call" => "%s{closure}()"
|
"call" => "%s{closure}()"
|
||||||
|
@ -39,7 +39,6 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
ob_start();
|
ob_start();
|
||||||
$dumper->dump($data);
|
$dumper->dump($data);
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
$closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function';
|
|
||||||
$out = preg_replace('/[ \t]+$/m', '', $out);
|
$out = preg_replace('/[ \t]+$/m', '', $out);
|
||||||
$var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8');
|
$var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8');
|
||||||
$intMax = PHP_INT_MAX;
|
$intMax = PHP_INT_MAX;
|
||||||
|
Reference in New Issue
Block a user