update v 1.0.7.5
This commit is contained in:
7
vendor/symfony/var-dumper/CHANGELOG.md
vendored
Normal file
7
vendor/symfony/var-dumper/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.7.0
|
||||
-----
|
||||
|
||||
* deprecated Cloner\Data::getLimitedClone(). Use withMaxDepth, withMaxItemsPerDepth or withRefHandles instead.
|
164
vendor/symfony/var-dumper/Caster/AmqpCaster.php
vendored
Normal file
164
vendor/symfony/var-dumper/Caster/AmqpCaster.php
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Amqp related classes to array representation.
|
||||
*
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
class AmqpCaster
|
||||
{
|
||||
private static $flags = array(
|
||||
AMQP_DURABLE => 'AMQP_DURABLE',
|
||||
AMQP_PASSIVE => 'AMQP_PASSIVE',
|
||||
AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE',
|
||||
AMQP_AUTODELETE => 'AMQP_AUTODELETE',
|
||||
AMQP_INTERNAL => 'AMQP_INTERNAL',
|
||||
AMQP_NOLOCAL => 'AMQP_NOLOCAL',
|
||||
AMQP_AUTOACK => 'AMQP_AUTOACK',
|
||||
AMQP_IFEMPTY => 'AMQP_IFEMPTY',
|
||||
AMQP_IFUNUSED => 'AMQP_IFUNUSED',
|
||||
AMQP_MANDATORY => 'AMQP_MANDATORY',
|
||||
AMQP_IMMEDIATE => 'AMQP_IMMEDIATE',
|
||||
AMQP_MULTIPLE => 'AMQP_MULTIPLE',
|
||||
AMQP_NOWAIT => 'AMQP_NOWAIT',
|
||||
AMQP_REQUEUE => 'AMQP_REQUEUE',
|
||||
);
|
||||
|
||||
private static $exchangeTypes = array(
|
||||
AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT',
|
||||
AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT',
|
||||
AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC',
|
||||
AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS',
|
||||
);
|
||||
|
||||
public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
// BC layer in the amqp lib
|
||||
if (method_exists($c, 'getReadTimeout')) {
|
||||
$timeout = $c->getReadTimeout();
|
||||
} else {
|
||||
$timeout = $c->getTimeout();
|
||||
}
|
||||
|
||||
$a += array(
|
||||
$prefix.'isConnected' => $c->isConnected(),
|
||||
$prefix.'login' => $c->getLogin(),
|
||||
$prefix.'password' => $c->getPassword(),
|
||||
$prefix.'host' => $c->getHost(),
|
||||
$prefix.'port' => $c->getPort(),
|
||||
$prefix.'vhost' => $c->getVhost(),
|
||||
$prefix.'readTimeout' => $timeout,
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += array(
|
||||
$prefix.'isConnected' => $c->isConnected(),
|
||||
$prefix.'channelId' => $c->getChannelId(),
|
||||
$prefix.'prefetchSize' => $c->getPrefetchSize(),
|
||||
$prefix.'prefetchCount' => $c->getPrefetchCount(),
|
||||
$prefix.'connection' => $c->getConnection(),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += array(
|
||||
$prefix.'name' => $c->getName(),
|
||||
$prefix.'flags' => self::extractFlags($c->getFlags()),
|
||||
$prefix.'arguments' => $c->getArguments(),
|
||||
$prefix.'connection' => $c->getConnection(),
|
||||
$prefix.'channel' => $c->getChannel(),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += array(
|
||||
$prefix.'name' => $c->getName(),
|
||||
$prefix.'flags' => self::extractFlags($c->getFlags()),
|
||||
$prefix.'type' => isset(self::$exchangeTypes[$c->getType()]) ? new ConstStub(self::$exchangeTypes[$c->getType()], $c->getType()) : $c->getType(),
|
||||
$prefix.'arguments' => $c->getArguments(),
|
||||
$prefix.'channel' => $c->getChannel(),
|
||||
$prefix.'connection' => $c->getConnection(),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||
$a += array($prefix.'body' => $c->getBody());
|
||||
}
|
||||
|
||||
$a += array(
|
||||
$prefix.'routingKey' => $c->getRoutingKey(),
|
||||
$prefix.'deliveryTag' => $c->getDeliveryTag(),
|
||||
$prefix.'deliveryMode' => new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode()),
|
||||
$prefix.'exchangeName' => $c->getExchangeName(),
|
||||
$prefix.'isRedelivery' => $c->isRedelivery(),
|
||||
$prefix.'contentType' => $c->getContentType(),
|
||||
$prefix.'contentEncoding' => $c->getContentEncoding(),
|
||||
$prefix.'type' => $c->getType(),
|
||||
$prefix.'timestamp' => $c->getTimestamp(),
|
||||
$prefix.'priority' => $c->getPriority(),
|
||||
$prefix.'expiration' => $c->getExpiration(),
|
||||
$prefix.'userId' => $c->getUserId(),
|
||||
$prefix.'appId' => $c->getAppId(),
|
||||
$prefix.'messageId' => $c->getMessageId(),
|
||||
$prefix.'replyTo' => $c->getReplyTo(),
|
||||
$prefix.'correlationId' => $c->getCorrelationId(),
|
||||
$prefix.'headers' => $c->getHeaders(),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function extractFlags($flags)
|
||||
{
|
||||
$flagsArray = array();
|
||||
|
||||
foreach (self::$flags as $value => $name) {
|
||||
if ($flags & $value) {
|
||||
$flagsArray[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$flagsArray) {
|
||||
$flagsArray = array('AMQP_NOPARAM');
|
||||
}
|
||||
|
||||
return new ConstStub(implode('|', $flagsArray), $flags);
|
||||
}
|
||||
}
|
116
vendor/symfony/var-dumper/Caster/Caster.php
vendored
Normal file
116
vendor/symfony/var-dumper/Caster/Caster.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
/**
|
||||
* Helper for filtering out properties in casters.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class Caster
|
||||
{
|
||||
const EXCLUDE_VERBOSE = 1;
|
||||
const EXCLUDE_VIRTUAL = 2;
|
||||
const EXCLUDE_DYNAMIC = 4;
|
||||
const EXCLUDE_PUBLIC = 8;
|
||||
const EXCLUDE_PROTECTED = 16;
|
||||
const EXCLUDE_PRIVATE = 32;
|
||||
const EXCLUDE_NULL = 64;
|
||||
const EXCLUDE_EMPTY = 128;
|
||||
const EXCLUDE_NOT_IMPORTANT = 256;
|
||||
const EXCLUDE_STRICT = 512;
|
||||
|
||||
const PREFIX_VIRTUAL = "\0~\0";
|
||||
const PREFIX_DYNAMIC = "\0+\0";
|
||||
const PREFIX_PROTECTED = "\0*\0";
|
||||
|
||||
/**
|
||||
* Casts objects to arrays and adds the dynamic property prefix.
|
||||
*
|
||||
* @param object $obj The object to cast.
|
||||
* @param \ReflectionClass $reflector The class reflector to use for inspecting the object definition.
|
||||
*
|
||||
* @return array The array-cast of the object, with prefixed dynamic properties.
|
||||
*/
|
||||
public static function castObject($obj, \ReflectionClass $reflector)
|
||||
{
|
||||
if ($reflector->hasMethod('__debugInfo')) {
|
||||
$a = $obj->__debugInfo();
|
||||
} else {
|
||||
$a = (array) $obj;
|
||||
}
|
||||
|
||||
if ($a) {
|
||||
$p = array_keys($a);
|
||||
foreach ($p as $i => $k) {
|
||||
if (!isset($k[0]) || ("\0" !== $k[0] && !$reflector->hasProperty($k))) {
|
||||
$p[$i] = self::PREFIX_DYNAMIC.$k;
|
||||
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
|
||||
$p[$i] = "\0".$reflector->getParentClass().'@anonymous'.strrchr($k, "\0");
|
||||
}
|
||||
}
|
||||
$a = array_combine($p, $a);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out the specified properties.
|
||||
*
|
||||
* By default, a single match in the $filter bit field filters properties out, following an "or" logic.
|
||||
* When EXCLUDE_STRICT is set, an "and" logic is applied: all bits must match for a property to be removed.
|
||||
*
|
||||
* @param array $a The array containing the properties to filter.
|
||||
* @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out.
|
||||
* @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set.
|
||||
*
|
||||
* @return array The filtered array
|
||||
*/
|
||||
public static function filter(array $a, $filter, array $listedProperties = array())
|
||||
{
|
||||
foreach ($a as $k => $v) {
|
||||
$type = self::EXCLUDE_STRICT & $filter;
|
||||
|
||||
if (null === $v) {
|
||||
$type |= self::EXCLUDE_NULL & $filter;
|
||||
}
|
||||
if (empty($v)) {
|
||||
$type |= self::EXCLUDE_EMPTY & $filter;
|
||||
}
|
||||
if ((self::EXCLUDE_NOT_IMPORTANT & $filter) && !in_array($k, $listedProperties, true)) {
|
||||
$type |= self::EXCLUDE_NOT_IMPORTANT;
|
||||
}
|
||||
if ((self::EXCLUDE_VERBOSE & $filter) && in_array($k, $listedProperties, true)) {
|
||||
$type |= self::EXCLUDE_VERBOSE;
|
||||
}
|
||||
|
||||
if (!isset($k[1]) || "\0" !== $k[0]) {
|
||||
$type |= self::EXCLUDE_PUBLIC & $filter;
|
||||
} elseif ('~' === $k[1]) {
|
||||
$type |= self::EXCLUDE_VIRTUAL & $filter;
|
||||
} elseif ('+' === $k[1]) {
|
||||
$type |= self::EXCLUDE_DYNAMIC & $filter;
|
||||
} elseif ('*' === $k[1]) {
|
||||
$type |= self::EXCLUDE_PROTECTED & $filter;
|
||||
} else {
|
||||
$type |= self::EXCLUDE_PRIVATE & $filter;
|
||||
}
|
||||
|
||||
if ((self::EXCLUDE_STRICT & $filter) ? $type === $filter : $type) {
|
||||
unset($a[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
30
vendor/symfony/var-dumper/Caster/CutArrayStub.php
vendored
Normal file
30
vendor/symfony/var-dumper/Caster/CutArrayStub.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
/**
|
||||
* Represents a cut array.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CutArrayStub extends CutStub
|
||||
{
|
||||
public $preservedSubset;
|
||||
|
||||
public function __construct(array $value, array $preservedKeys)
|
||||
{
|
||||
parent::__construct($value);
|
||||
|
||||
$this->preservedSubset = array_intersect_key($value, array_flip($preservedKeys));
|
||||
$this->cut -= count($this->preservedSubset);
|
||||
}
|
||||
}
|
@@ -48,7 +48,7 @@ class CutStub extends Stub
|
||||
case 'string':
|
||||
$this->type = self::TYPE_STRING;
|
||||
$this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY;
|
||||
$this->cut = self::STRING_BINARY === $this->class ? strlen($value) : (function_exists('iconv_strlen') ? iconv_strlen($value, 'UTF-8') : -1);
|
||||
$this->cut = self::STRING_BINARY === $this->class ? strlen($value) : mb_strlen($value, 'UTF-8');
|
||||
$this->value = '';
|
||||
break;
|
||||
}
|
@@ -63,7 +63,7 @@ class DOMCaster
|
||||
|
||||
public static function castException(\DOMException $e, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$k = "\0*\0code";
|
||||
$k = Caster::PREFIX_PROTECTED.'code';
|
||||
if (isset($a[$k], self::$errorCodes[$a[$k]])) {
|
||||
$a[$k] = new ConstStub(self::$errorCodes[$a[$k]], $a[$k]);
|
||||
}
|
||||
@@ -83,8 +83,8 @@ class DOMCaster
|
||||
public static function castImplementation($dom, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a += array(
|
||||
"\0~\0Core" => '1.0',
|
||||
"\0~\0XML" => '2.0',
|
||||
Caster::PREFIX_VIRTUAL.'Core' => '1.0',
|
||||
Caster::PREFIX_VIRTUAL.'XML' => '2.0',
|
||||
);
|
||||
|
||||
return $a;
|
||||
@@ -130,11 +130,8 @@ class DOMCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested)
|
||||
public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
{
|
||||
$formatOutput = $dom->formatOutput;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$a += array(
|
||||
'doctype' => $dom->doctype,
|
||||
'implementation' => $dom->implementation,
|
||||
@@ -149,16 +146,20 @@ class DOMCaster
|
||||
'strictErrorChecking' => $dom->strictErrorChecking,
|
||||
'documentURI' => $dom->documentURI,
|
||||
'config' => $dom->config,
|
||||
'formatOutput' => $formatOutput,
|
||||
'formatOutput' => $dom->formatOutput,
|
||||
'validateOnParse' => $dom->validateOnParse,
|
||||
'resolveExternals' => $dom->resolveExternals,
|
||||
'preserveWhiteSpace' => $dom->preserveWhiteSpace,
|
||||
'recover' => $dom->recover,
|
||||
'substituteEntities' => $dom->substituteEntities,
|
||||
"\0~\0xml" => $dom->saveXML(),
|
||||
);
|
||||
|
||||
$dom->formatOutput = $formatOutput;
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||
$formatOutput = $dom->formatOutput;
|
||||
$dom->formatOutput = true;
|
||||
$a += array(Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML());
|
||||
$dom->formatOutput = $formatOutput;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
27
vendor/symfony/var-dumper/Caster/EnumStub.php
vendored
Normal file
27
vendor/symfony/var-dumper/Caster/EnumStub.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents an enumeration of values.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class EnumStub extends Stub
|
||||
{
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->value = $values;
|
||||
}
|
||||
}
|
238
vendor/symfony/var-dumper/Caster/ExceptionCaster.php
vendored
Normal file
238
vendor/symfony/var-dumper/Caster/ExceptionCaster.php
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Exception\ThrowingCasterException;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts common Exception classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ExceptionCaster
|
||||
{
|
||||
public static $srcContext = 1;
|
||||
public static $traceArgs = true;
|
||||
public static $errorTypes = array(
|
||||
E_DEPRECATED => 'E_DEPRECATED',
|
||||
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
|
||||
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
|
||||
E_ERROR => 'E_ERROR',
|
||||
E_WARNING => 'E_WARNING',
|
||||
E_PARSE => 'E_PARSE',
|
||||
E_NOTICE => 'E_NOTICE',
|
||||
E_CORE_ERROR => 'E_CORE_ERROR',
|
||||
E_CORE_WARNING => 'E_CORE_WARNING',
|
||||
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
|
||||
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
|
||||
E_USER_ERROR => 'E_USER_ERROR',
|
||||
E_USER_WARNING => 'E_USER_WARNING',
|
||||
E_USER_NOTICE => 'E_USER_NOTICE',
|
||||
E_STRICT => 'E_STRICT',
|
||||
);
|
||||
|
||||
public static function castError(\Error $e, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
{
|
||||
return self::filterExceptionArray($stub->class, $a, "\0Error\0", $filter);
|
||||
}
|
||||
|
||||
public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
{
|
||||
return self::filterExceptionArray($stub->class, $a, "\0Exception\0", $filter);
|
||||
}
|
||||
|
||||
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) {
|
||||
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_PROTECTED;
|
||||
$xPrefix = "\0Exception\0";
|
||||
|
||||
if (isset($a[$xPrefix.'previous'], $a[$xPrefix.'trace'])) {
|
||||
$b = (array) $a[$xPrefix.'previous'];
|
||||
array_unshift($b[$xPrefix.'trace'], array(
|
||||
'function' => 'new '.get_class($a[$xPrefix.'previous']),
|
||||
'file' => $b[$prefix.'file'],
|
||||
'line' => $b[$prefix.'line'],
|
||||
));
|
||||
$a[$xPrefix.'trace'] = new TraceStub($b[$xPrefix.'trace'], false, 0, -1 - count($a[$xPrefix.'trace']->value));
|
||||
}
|
||||
|
||||
unset($a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if (!$isNested) {
|
||||
return $a;
|
||||
}
|
||||
$stub->class = '';
|
||||
$stub->handle = 0;
|
||||
$frames = $trace->value;
|
||||
|
||||
$a = array();
|
||||
$j = count($frames);
|
||||
if (0 > $i = $trace->sliceOffset) {
|
||||
$i = max(0, $j + $i);
|
||||
}
|
||||
if (!isset($trace->value[$i])) {
|
||||
return array();
|
||||
}
|
||||
$lastCall = isset($frames[$i]['function']) ? ' ==> '.(isset($frames[$i]['class']) ? $frames[0]['class'].$frames[$i]['type'] : '').$frames[$i]['function'].'()' : '';
|
||||
|
||||
for ($j += $trace->numberingOffset - $i++; isset($frames[$i]); ++$i, --$j) {
|
||||
$call = isset($frames[$i]['function']) ? (isset($frames[$i]['class']) ? $frames[$i]['class'].$frames[$i]['type'] : '').$frames[$i]['function'].'()' : '???';
|
||||
|
||||
$a[Caster::PREFIX_VIRTUAL.$j.'. '.$call.$lastCall] = new FrameStub(
|
||||
array(
|
||||
'object' => isset($frames[$i]['object']) ? $frames[$i]['object'] : null,
|
||||
'class' => isset($frames[$i]['class']) ? $frames[$i]['class'] : null,
|
||||
'type' => isset($frames[$i]['type']) ? $frames[$i]['type'] : null,
|
||||
'function' => isset($frames[$i]['function']) ? $frames[$i]['function'] : null,
|
||||
) + $frames[$i - 1],
|
||||
$trace->keepArgs,
|
||||
true
|
||||
);
|
||||
|
||||
$lastCall = ' ==> '.$call;
|
||||
}
|
||||
$a[Caster::PREFIX_VIRTUAL.$j.'. {main}'.$lastCall] = new FrameStub(
|
||||
array(
|
||||
'object' => null,
|
||||
'class' => null,
|
||||
'type' => null,
|
||||
'function' => '{main}',
|
||||
) + $frames[$i - 1],
|
||||
$trace->keepArgs,
|
||||
true
|
||||
);
|
||||
if (null !== $trace->sliceLength) {
|
||||
$a = array_slice($a, 0, $trace->sliceLength, true);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if (!$isNested) {
|
||||
return $a;
|
||||
}
|
||||
$f = $frame->value;
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if (isset($f['file'], $f['line'])) {
|
||||
if (preg_match('/\((\d+)\)(?:\([\da-f]{32}\))? : (?:eval\(\)\'d code|runtime-created function)$/', $f['file'], $match)) {
|
||||
$f['file'] = substr($f['file'], 0, -strlen($match[0]));
|
||||
$f['line'] = (int) $match[1];
|
||||
}
|
||||
if (file_exists($f['file']) && 0 <= self::$srcContext) {
|
||||
$src[$f['file'].':'.$f['line']] = self::extractSource(explode("\n", file_get_contents($f['file'])), $f['line'], self::$srcContext);
|
||||
|
||||
if (!empty($f['class']) && is_subclass_of($f['class'], 'Twig_Template') && method_exists($f['class'], 'getDebugInfo')) {
|
||||
$template = isset($f['object']) ? $f['object'] : new $f['class'](new \Twig_Environment(new \Twig_Loader_Filesystem()));
|
||||
|
||||
try {
|
||||
$templateName = $template->getTemplateName();
|
||||
$templateSrc = explode("\n", method_exists($template, 'getSource') ? $template->getSource() : $template->getEnvironment()->getLoader()->getSource($templateName));
|
||||
$templateInfo = $template->getDebugInfo();
|
||||
if (isset($templateInfo[$f['line']])) {
|
||||
$src[$templateName.':'.$templateInfo[$f['line']]] = self::extractSource($templateSrc, $templateInfo[$f['line']], self::$srcContext);
|
||||
}
|
||||
} catch (\Twig_Error_Loader $e) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$src[$f['file']] = $f['line'];
|
||||
}
|
||||
$a[$prefix.'src'] = new EnumStub($src);
|
||||
}
|
||||
|
||||
unset($a[$prefix.'args'], $a[$prefix.'line'], $a[$prefix.'file']);
|
||||
if ($frame->inTraceStub) {
|
||||
unset($a[$prefix.'class'], $a[$prefix.'type'], $a[$prefix.'function']);
|
||||
}
|
||||
foreach ($a as $k => $v) {
|
||||
if (!$v) {
|
||||
unset($a[$k]);
|
||||
}
|
||||
}
|
||||
if ($frame->keepArgs && isset($f['args'])) {
|
||||
$a[$prefix.'args'] = $f['args'];
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function filterExceptionArray($xClass, array $a, $xPrefix, $filter)
|
||||
{
|
||||
if (isset($a[$xPrefix.'trace'])) {
|
||||
$trace = $a[$xPrefix.'trace'];
|
||||
unset($a[$xPrefix.'trace']); // Ensures the trace is always last
|
||||
} else {
|
||||
$trace = array();
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||
array_unshift($trace, array(
|
||||
'function' => $xClass ? 'new '.$xClass : null,
|
||||
'file' => $a[Caster::PREFIX_PROTECTED.'file'],
|
||||
'line' => $a[Caster::PREFIX_PROTECTED.'line'],
|
||||
));
|
||||
$a[$xPrefix.'trace'] = new TraceStub($trace);
|
||||
}
|
||||
if (empty($a[$xPrefix.'previous'])) {
|
||||
unset($a[$xPrefix.'previous']);
|
||||
}
|
||||
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function extractSource(array $srcArray, $line, $srcContext)
|
||||
{
|
||||
$src = array();
|
||||
|
||||
for ($i = $line - 1 - $srcContext; $i <= $line - 1 + $srcContext; ++$i) {
|
||||
$src[] = (isset($srcArray[$i]) ? $srcArray[$i] : '')."\n";
|
||||
}
|
||||
|
||||
$ltrim = 0;
|
||||
while (' ' === $src[0][$ltrim] || "\t" === $src[0][$ltrim]) {
|
||||
$i = $srcContext << 1;
|
||||
while ($i > 0 && $src[0][$ltrim] === $src[$i][$ltrim]) {
|
||||
--$i;
|
||||
}
|
||||
if ($i) {
|
||||
break;
|
||||
}
|
||||
++$ltrim;
|
||||
}
|
||||
if ($ltrim) {
|
||||
foreach ($src as $i => $line) {
|
||||
$src[$i] = substr($line, $ltrim);
|
||||
}
|
||||
}
|
||||
|
||||
return implode('', $src);
|
||||
}
|
||||
}
|
30
vendor/symfony/var-dumper/Caster/FrameStub.php
vendored
Normal file
30
vendor/symfony/var-dumper/Caster/FrameStub.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
/**
|
||||
* Represents a single backtrace frame as returned by debug_backtrace() or Exception->getTrace().
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class FrameStub extends EnumStub
|
||||
{
|
||||
public $keepArgs;
|
||||
public $inTraceStub;
|
||||
|
||||
public function __construct(array $frame, $keepArgs = true, $inTraceStub = false)
|
||||
{
|
||||
$this->value = $frame;
|
||||
$this->keepArgs = $keepArgs;
|
||||
$this->inTraceStub = $inTraceStub;
|
||||
}
|
||||
}
|
34
vendor/symfony/var-dumper/Caster/MongoCaster.php
vendored
Normal file
34
vendor/symfony/var-dumper/Caster/MongoCaster.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts classes from the MongoDb extension to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class MongoCaster
|
||||
{
|
||||
public static function castCursor(\MongoCursorInterface $cursor, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if ($info = $cursor->info()) {
|
||||
foreach ($info as $k => $v) {
|
||||
$a[Caster::PREFIX_VIRTUAL.$k] = $v;
|
||||
}
|
||||
}
|
||||
$a[Caster::PREFIX_VIRTUAL.'dead'] = $cursor->dead();
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
@@ -78,11 +78,11 @@ class PdoCaster
|
||||
}
|
||||
}
|
||||
|
||||
$prefix = "\0~\0";
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$a += array(
|
||||
$prefix.'inTransaction' => method_exists($c, 'inTransaction'),
|
||||
$prefix.'errorInfo' => $c->errorInfo(),
|
||||
$prefix.'attributes' => $attr,
|
||||
$prefix.'attributes' => new EnumStub($attr),
|
||||
);
|
||||
|
||||
if ($a[$prefix.'inTransaction']) {
|
||||
@@ -102,7 +102,7 @@ class PdoCaster
|
||||
|
||||
public static function castPdoStatement(\PDOStatement $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = "\0~\0";
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$a[$prefix.'errorInfo'] = $c->errorInfo();
|
||||
|
||||
if (!isset($a[$prefix.'errorInfo'][1], $a[$prefix.'errorInfo'][2])) {
|
154
vendor/symfony/var-dumper/Caster/PgSqlCaster.php
vendored
Normal file
154
vendor/symfony/var-dumper/Caster/PgSqlCaster.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts pqsql resources to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class PgSqlCaster
|
||||
{
|
||||
private static $paramCodes = array(
|
||||
'server_encoding',
|
||||
'client_encoding',
|
||||
'is_superuser',
|
||||
'session_authorization',
|
||||
'DateStyle',
|
||||
'TimeZone',
|
||||
'IntervalStyle',
|
||||
'integer_datetimes',
|
||||
'application_name',
|
||||
'standard_conforming_strings',
|
||||
);
|
||||
|
||||
private static $transactionStatus = array(
|
||||
PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE',
|
||||
PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE',
|
||||
PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS',
|
||||
PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR',
|
||||
PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN',
|
||||
);
|
||||
|
||||
private static $resultStatus = array(
|
||||
PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY',
|
||||
PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK',
|
||||
PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK',
|
||||
PGSQL_COPY_OUT => 'PGSQL_COPY_OUT',
|
||||
PGSQL_COPY_IN => 'PGSQL_COPY_IN',
|
||||
PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE',
|
||||
PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR',
|
||||
PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR',
|
||||
);
|
||||
|
||||
private static $diagCodes = array(
|
||||
'severity' => PGSQL_DIAG_SEVERITY,
|
||||
'sqlstate' => PGSQL_DIAG_SQLSTATE,
|
||||
'message' => PGSQL_DIAG_MESSAGE_PRIMARY,
|
||||
'detail' => PGSQL_DIAG_MESSAGE_DETAIL,
|
||||
'hint' => PGSQL_DIAG_MESSAGE_HINT,
|
||||
'statement position' => PGSQL_DIAG_STATEMENT_POSITION,
|
||||
'internal position' => PGSQL_DIAG_INTERNAL_POSITION,
|
||||
'internal query' => PGSQL_DIAG_INTERNAL_QUERY,
|
||||
'context' => PGSQL_DIAG_CONTEXT,
|
||||
'file' => PGSQL_DIAG_SOURCE_FILE,
|
||||
'line' => PGSQL_DIAG_SOURCE_LINE,
|
||||
'function' => PGSQL_DIAG_SOURCE_FUNCTION,
|
||||
);
|
||||
|
||||
public static function castLargeObject($lo, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a['seek position'] = pg_lo_tell($lo);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castLink($link, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a['status'] = pg_connection_status($link);
|
||||
$a['status'] = new ConstStub(PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']);
|
||||
$a['busy'] = pg_connection_busy($link);
|
||||
|
||||
$a['transaction'] = pg_transaction_status($link);
|
||||
if (isset(self::$transactionStatus[$a['transaction']])) {
|
||||
$a['transaction'] = new ConstStub(self::$transactionStatus[$a['transaction']], $a['transaction']);
|
||||
}
|
||||
|
||||
$a['pid'] = pg_get_pid($link);
|
||||
$a['last error'] = pg_last_error($link);
|
||||
$a['last notice'] = pg_last_notice($link);
|
||||
$a['host'] = pg_host($link);
|
||||
$a['port'] = pg_port($link);
|
||||
$a['dbname'] = pg_dbname($link);
|
||||
$a['options'] = pg_options($link);
|
||||
$a['version'] = pg_version($link);
|
||||
|
||||
foreach (self::$paramCodes as $v) {
|
||||
if (false !== $s = pg_parameter_status($link, $v)) {
|
||||
$a['param'][$v] = $s;
|
||||
}
|
||||
}
|
||||
|
||||
$a['param']['client_encoding'] = pg_client_encoding($link);
|
||||
$a['param'] = new EnumStub($a['param']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castResult($result, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a['num rows'] = pg_num_rows($result);
|
||||
$a['status'] = pg_result_status($result);
|
||||
if (isset(self::$resultStatus[$a['status']])) {
|
||||
$a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
|
||||
}
|
||||
$a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
|
||||
|
||||
if (-1 === $a['num rows']) {
|
||||
foreach (self::$diagCodes as $k => $v) {
|
||||
$a['error'][$k] = pg_result_error_field($result, $v);
|
||||
}
|
||||
}
|
||||
|
||||
$a['affected rows'] = pg_affected_rows($result);
|
||||
$a['last OID'] = pg_last_oid($result);
|
||||
|
||||
$fields = pg_num_fields($result);
|
||||
|
||||
for ($i = 0; $i < $fields; ++$i) {
|
||||
$field = array(
|
||||
'name' => pg_field_name($result, $i),
|
||||
'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)),
|
||||
'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)),
|
||||
'nullable' => (bool) pg_field_is_null($result, $i),
|
||||
'storage' => pg_field_size($result, $i).' bytes',
|
||||
'display' => pg_field_prtlen($result, $i).' chars',
|
||||
);
|
||||
if (' (OID: )' === $field['table']) {
|
||||
$field['table'] = null;
|
||||
}
|
||||
if ('-1 bytes' === $field['storage']) {
|
||||
$field['storage'] = 'variable size';
|
||||
} elseif ('1 bytes' === $field['storage']) {
|
||||
$field['storage'] = '1 byte';
|
||||
}
|
||||
if ('1 chars' === $field['display']) {
|
||||
$field['display'] = '1 char';
|
||||
}
|
||||
$a['fields'][] = new EnumStub($field);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
309
vendor/symfony/var-dumper/Caster/ReflectionCaster.php
vendored
Normal file
309
vendor/symfony/var-dumper/Caster/ReflectionCaster.php
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Reflector related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ReflectionCaster
|
||||
{
|
||||
private static $extraMap = array(
|
||||
'docComment' => 'getDocComment',
|
||||
'extension' => 'getExtensionName',
|
||||
'isDisabled' => 'isDisabled',
|
||||
'isDeprecated' => 'isDeprecated',
|
||||
'isInternal' => 'isInternal',
|
||||
'isUserDefined' => 'isUserDefined',
|
||||
'isGenerator' => 'isGenerator',
|
||||
'isVariadic' => 'isVariadic',
|
||||
);
|
||||
|
||||
public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$c = new \ReflectionFunction($c);
|
||||
|
||||
$stub->class = 'Closure'; // HHVM generates unique class names for closures
|
||||
$a = static::castFunctionAbstract($c, $a, $stub, $isNested);
|
||||
|
||||
if (isset($a[$prefix.'parameters'])) {
|
||||
foreach ($a[$prefix.'parameters']->value as &$v) {
|
||||
$param = $v;
|
||||
$v = new EnumStub(array());
|
||||
foreach (static::castParameter($param, array(), $stub, true) as $k => $param) {
|
||||
if ("\0" === $k[0]) {
|
||||
$v->value[substr($k, 3)] = $param;
|
||||
}
|
||||
}
|
||||
unset($v->value['position'], $v->value['isVariadic'], $v->value['byReference'], $v);
|
||||
}
|
||||
}
|
||||
|
||||
if ($f = $c->getFileName()) {
|
||||
$a[$prefix.'file'] = $f;
|
||||
$a[$prefix.'line'] = $c->getStartLine().' to '.$c->getEndLine();
|
||||
}
|
||||
|
||||
$prefix = Caster::PREFIX_DYNAMIC;
|
||||
unset($a['name'], $a[$prefix.'0'], $a[$prefix.'this'], $a[$prefix.'parameter'], $a[Caster::PREFIX_VIRTUAL.'extra']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castGenerator(\Generator $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
return class_exists('ReflectionGenerator', false) ? self::castReflectionGenerator(new \ReflectionGenerator($c), $a, $stub, $isNested) : $a;
|
||||
}
|
||||
|
||||
public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += array(
|
||||
$prefix.'type' => $c->__toString(),
|
||||
$prefix.'allowsNull' => $c->allowsNull(),
|
||||
$prefix.'isBuiltin' => $c->isBuiltin(),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if ($c->getThis()) {
|
||||
$a[$prefix.'this'] = new CutStub($c->getThis());
|
||||
}
|
||||
$x = $c->getFunction();
|
||||
$frame = array(
|
||||
'class' => isset($x->class) ? $x->class : null,
|
||||
'type' => isset($x->class) ? ($x->isStatic() ? '::' : '->') : null,
|
||||
'function' => $x->name,
|
||||
'file' => $c->getExecutingFile(),
|
||||
'line' => $c->getExecutingLine(),
|
||||
);
|
||||
if ($trace = $c->getTrace(DEBUG_BACKTRACE_IGNORE_ARGS)) {
|
||||
$x = new \ReflectionGenerator($c->getExecutingGenerator());
|
||||
array_unshift($trace, array(
|
||||
'function' => 'yield',
|
||||
'file' => $x->getExecutingFile(),
|
||||
'line' => $x->getExecutingLine() - 1,
|
||||
));
|
||||
$trace[] = $frame;
|
||||
$a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1);
|
||||
} else {
|
||||
$x = new FrameStub($frame, false, true);
|
||||
$x = ExceptionCaster::castFrameStub($x, array(), $x, true);
|
||||
$a[$prefix.'executing'] = new EnumStub(array(
|
||||
$frame['class'].$frame['type'].$frame['function'].'()' => $x[$prefix.'src'],
|
||||
));
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castClass(\ReflectionClass $c, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if ($n = \Reflection::getModifierNames($c->getModifiers())) {
|
||||
$a[$prefix.'modifiers'] = implode(' ', $n);
|
||||
}
|
||||
|
||||
self::addMap($a, $c, array(
|
||||
'extends' => 'getParentClass',
|
||||
'implements' => 'getInterfaceNames',
|
||||
'constants' => 'getConstants',
|
||||
));
|
||||
|
||||
foreach ($c->getProperties() as $n) {
|
||||
$a[$prefix.'properties'][$n->name] = $n;
|
||||
}
|
||||
|
||||
foreach ($c->getMethods() as $n) {
|
||||
$a[$prefix.'methods'][$n->name] = $n;
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) {
|
||||
self::addExtra($a, $c);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
self::addMap($a, $c, array(
|
||||
'returnsReference' => 'returnsReference',
|
||||
'returnType' => 'getReturnType',
|
||||
'class' => 'getClosureScopeClass',
|
||||
'this' => 'getClosureThis',
|
||||
));
|
||||
|
||||
if (isset($a[$prefix.'returnType'])) {
|
||||
$a[$prefix.'returnType'] = (string) $a[$prefix.'returnType'];
|
||||
}
|
||||
if (isset($a[$prefix.'this'])) {
|
||||
$a[$prefix.'this'] = new CutStub($a[$prefix.'this']);
|
||||
}
|
||||
|
||||
foreach ($c->getParameters() as $v) {
|
||||
$k = '$'.$v->name;
|
||||
if ($v->isPassedByReference()) {
|
||||
$k = '&'.$k;
|
||||
}
|
||||
if (method_exists($v, 'isVariadic') && $v->isVariadic()) {
|
||||
$k = '...'.$k;
|
||||
}
|
||||
$a[$prefix.'parameters'][$k] = $v;
|
||||
}
|
||||
if (isset($a[$prefix.'parameters'])) {
|
||||
$a[$prefix.'parameters'] = new EnumStub($a[$prefix.'parameters']);
|
||||
}
|
||||
|
||||
if ($v = $c->getStaticVariables()) {
|
||||
foreach ($v as $k => &$v) {
|
||||
$a[$prefix.'use']['$'.$k] = &$v;
|
||||
}
|
||||
unset($v);
|
||||
$a[$prefix.'use'] = new EnumStub($a[$prefix.'use']);
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) {
|
||||
self::addExtra($a, $c);
|
||||
}
|
||||
|
||||
// Added by HHVM
|
||||
unset($a[Caster::PREFIX_DYNAMIC.'static']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers()));
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
// Added by HHVM
|
||||
unset($a['info']);
|
||||
|
||||
self::addMap($a, $c, array(
|
||||
'position' => 'getPosition',
|
||||
'isVariadic' => 'isVariadic',
|
||||
'byReference' => 'isPassedByReference',
|
||||
));
|
||||
|
||||
try {
|
||||
if (method_exists($c, 'hasType')) {
|
||||
if ($c->hasType()) {
|
||||
$a[$prefix.'typeHint'] = $c->getType()->__toString();
|
||||
}
|
||||
} else {
|
||||
$v = explode(' ', $c->__toString(), 6);
|
||||
if (isset($v[5]) && 0 === strspn($v[4], '.&$')) {
|
||||
$a[$prefix.'typeHint'] = $v[4];
|
||||
}
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
if (preg_match('/^Class ([^ ]++) does not exist$/', $e->getMessage(), $m)) {
|
||||
$a[$prefix.'typeHint'] = $m[1];
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$a[$prefix.'default'] = $v = $c->getDefaultValue();
|
||||
if (method_exists($c, 'isDefaultValueConstant') && $c->isDefaultValueConstant()) {
|
||||
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
if (isset($a[$prefix.'typeHint']) && $c->allowsNull()) {
|
||||
$a[$prefix.'default'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers()));
|
||||
self::addExtra($a, $c);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
self::addMap($a, $c, array(
|
||||
'version' => 'getVersion',
|
||||
'dependencies' => 'getDependencies',
|
||||
'iniEntries' => 'getIniEntries',
|
||||
'isPersistent' => 'isPersistent',
|
||||
'isTemporary' => 'isTemporary',
|
||||
'constants' => 'getConstants',
|
||||
'functions' => 'getFunctions',
|
||||
'classes' => 'getClasses',
|
||||
));
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
self::addMap($a, $c, array(
|
||||
'version' => 'getVersion',
|
||||
'author' => 'getAuthor',
|
||||
'copyright' => 'getCopyright',
|
||||
'url' => 'getURL',
|
||||
));
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function addExtra(&$a, \Reflector $c)
|
||||
{
|
||||
$x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : array();
|
||||
|
||||
if (method_exists($c, 'getFileName') && $m = $c->getFileName()) {
|
||||
$x['file'] = $m;
|
||||
$x['line'] = $c->getStartLine().' to '.$c->getEndLine();
|
||||
}
|
||||
|
||||
self::addMap($x, $c, self::$extraMap, '');
|
||||
|
||||
if ($x) {
|
||||
$a[Caster::PREFIX_VIRTUAL.'extra'] = new EnumStub($x);
|
||||
}
|
||||
}
|
||||
|
||||
private static function addMap(&$a, \Reflector $c, $map, $prefix = Caster::PREFIX_VIRTUAL)
|
||||
{
|
||||
foreach ($map as $k => $m) {
|
||||
if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) {
|
||||
$a[$prefix.$k] = $m instanceof \Reflector ? $m->name : $m;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
203
vendor/symfony/var-dumper/Caster/SplCaster.php
vendored
Normal file
203
vendor/symfony/var-dumper/Caster/SplCaster.php
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts SPL related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class SplCaster
|
||||
{
|
||||
private static $splFileObjectFlags = array(
|
||||
\SplFileObject::DROP_NEW_LINE => 'DROP_NEW_LINE',
|
||||
\SplFileObject::READ_AHEAD => 'READ_AHEAD',
|
||||
\SplFileObject::SKIP_EMPTY => 'SKIP_EMPTY',
|
||||
\SplFileObject::READ_CSV => 'READ_CSV',
|
||||
);
|
||||
|
||||
public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$class = $stub->class;
|
||||
$flags = $c->getFlags();
|
||||
|
||||
$b = array(
|
||||
$prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
|
||||
$prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
|
||||
$prefix.'iteratorClass' => $c->getIteratorClass(),
|
||||
$prefix.'storage' => $c->getArrayCopy(),
|
||||
);
|
||||
|
||||
if ($class === 'ArrayObject') {
|
||||
$a = $b;
|
||||
} else {
|
||||
if (!($flags & \ArrayObject::STD_PROP_LIST)) {
|
||||
$c->setFlags(\ArrayObject::STD_PROP_LIST);
|
||||
$a = Caster::castObject($c, new \ReflectionClass($class));
|
||||
$c->setFlags($flags);
|
||||
}
|
||||
|
||||
$a += $b;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castHeap(\Iterator $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a += array(
|
||||
Caster::PREFIX_VIRTUAL.'heap' => iterator_to_array(clone $c),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$mode = $c->getIteratorMode();
|
||||
$c->setIteratorMode(\SplDoublyLinkedList::IT_MODE_KEEP | $mode & ~\SplDoublyLinkedList::IT_MODE_DELETE);
|
||||
|
||||
$a += array(
|
||||
$prefix.'mode' => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_KEEP) ? 'IT_MODE_KEEP' : 'IT_MODE_DELETE'), $mode),
|
||||
$prefix.'dllist' => iterator_to_array($c),
|
||||
);
|
||||
$c->setIteratorMode($mode);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
static $map = array(
|
||||
'path' => 'getPath',
|
||||
'filename' => 'getFilename',
|
||||
'basename' => 'getBasename',
|
||||
'pathname' => 'getPathname',
|
||||
'extension' => 'getExtension',
|
||||
'realPath' => 'getRealPath',
|
||||
'aTime' => 'getATime',
|
||||
'mTime' => 'getMTime',
|
||||
'cTime' => 'getCTime',
|
||||
'inode' => 'getInode',
|
||||
'size' => 'getSize',
|
||||
'perms' => 'getPerms',
|
||||
'owner' => 'getOwner',
|
||||
'group' => 'getGroup',
|
||||
'type' => 'getType',
|
||||
'writable' => 'isWritable',
|
||||
'readable' => 'isReadable',
|
||||
'executable' => 'isExecutable',
|
||||
'file' => 'isFile',
|
||||
'dir' => 'isDir',
|
||||
'link' => 'isLink',
|
||||
'linkTarget' => 'getLinkTarget',
|
||||
);
|
||||
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
foreach ($map as $key => $accessor) {
|
||||
try {
|
||||
$a[$prefix.$key] = $c->$accessor();
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'perms'])) {
|
||||
$a[$prefix.'perms'] = new ConstStub(sprintf('0%o', $a[$prefix.'perms']), $a[$prefix.'perms']);
|
||||
}
|
||||
|
||||
static $mapDate = array('aTime', 'mTime', 'cTime');
|
||||
foreach ($mapDate as $key) {
|
||||
if (isset($a[$prefix.$key])) {
|
||||
$a[$prefix.$key] = new ConstStub(date('Y-m-d H:i:s', $a[$prefix.$key]), $a[$prefix.$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
static $map = array(
|
||||
'csvControl' => 'getCsvControl',
|
||||
'flags' => 'getFlags',
|
||||
'maxLineLen' => 'getMaxLineLen',
|
||||
'fstat' => 'fstat',
|
||||
'eof' => 'eof',
|
||||
'key' => 'key',
|
||||
);
|
||||
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
foreach ($map as $key => $accessor) {
|
||||
try {
|
||||
$a[$prefix.$key] = $c->$accessor();
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'flags'])) {
|
||||
$flagsArray = array();
|
||||
foreach (self::$splFileObjectFlags as $value => $name) {
|
||||
if ($a[$prefix.'flags'] & $value) {
|
||||
$flagsArray[] = $name;
|
||||
}
|
||||
}
|
||||
$a[$prefix.'flags'] = new ConstStub(implode('|', $flagsArray), $a[$prefix.'flags']);
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'fstat'])) {
|
||||
$a[$prefix.'fstat'] = new CutArrayStub($a[$prefix.'fstat'], array('dev', 'ino', 'nlink', 'rdev', 'blksize', 'blocks'));
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a += array(
|
||||
Caster::PREFIX_VIRTUAL.'storage' => $c->toArray(),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$storage = array();
|
||||
unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967
|
||||
|
||||
foreach ($c as $obj) {
|
||||
$storage[spl_object_hash($obj)] = array(
|
||||
'object' => $obj,
|
||||
'info' => $c->getInfo(),
|
||||
);
|
||||
}
|
||||
|
||||
$a += array(
|
||||
Caster::PREFIX_VIRTUAL.'storage' => $storage,
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'innerIterator'] = $c->getInnerIterator();
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
@@ -33,6 +33,11 @@ class StubCaster
|
||||
}
|
||||
}
|
||||
|
||||
public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
return $isNested ? $c->preservedSubset : $a;
|
||||
}
|
||||
|
||||
public static function cutInternals($obj, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if ($isNested) {
|
||||
@@ -43,4 +48,25 @@ class StubCaster
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castEnum(EnumStub $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if ($isNested) {
|
||||
$stub->class = '';
|
||||
$stub->handle = 0;
|
||||
$stub->value = null;
|
||||
|
||||
$a = array();
|
||||
|
||||
if ($c->value) {
|
||||
foreach (array_keys($c->value) as $k) {
|
||||
$keys[] = Caster::PREFIX_VIRTUAL.$k;
|
||||
}
|
||||
// Preserve references with array_combine()
|
||||
$a = array_combine($keys, $c->value);
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
36
vendor/symfony/var-dumper/Caster/TraceStub.php
vendored
Normal file
36
vendor/symfony/var-dumper/Caster/TraceStub.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents a backtrace as returned by debug_backtrace() or Exception->getTrace().
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class TraceStub extends Stub
|
||||
{
|
||||
public $keepArgs;
|
||||
public $sliceOffset;
|
||||
public $sliceLength;
|
||||
public $numberingOffset;
|
||||
|
||||
public function __construct(array $trace, $keepArgs = true, $sliceOffset = 0, $sliceLength = null, $numberingOffset = 0)
|
||||
{
|
||||
$this->value = $trace;
|
||||
$this->keepArgs = $keepArgs;
|
||||
$this->sliceOffset = $sliceOffset;
|
||||
$this->sliceLength = $sliceLength;
|
||||
$this->numberingOffset = $numberingOffset;
|
||||
}
|
||||
}
|
61
vendor/symfony/var-dumper/Caster/XmlResourceCaster.php
vendored
Normal file
61
vendor/symfony/var-dumper/Caster/XmlResourceCaster.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts XML resources to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class XmlResourceCaster
|
||||
{
|
||||
private static $xmlErrors = array(
|
||||
XML_ERROR_NONE => 'XML_ERROR_NONE',
|
||||
XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY',
|
||||
XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX',
|
||||
XML_ERROR_NO_ELEMENTS => 'XML_ERROR_NO_ELEMENTS',
|
||||
XML_ERROR_INVALID_TOKEN => 'XML_ERROR_INVALID_TOKEN',
|
||||
XML_ERROR_UNCLOSED_TOKEN => 'XML_ERROR_UNCLOSED_TOKEN',
|
||||
XML_ERROR_PARTIAL_CHAR => 'XML_ERROR_PARTIAL_CHAR',
|
||||
XML_ERROR_TAG_MISMATCH => 'XML_ERROR_TAG_MISMATCH',
|
||||
XML_ERROR_DUPLICATE_ATTRIBUTE => 'XML_ERROR_DUPLICATE_ATTRIBUTE',
|
||||
XML_ERROR_JUNK_AFTER_DOC_ELEMENT => 'XML_ERROR_JUNK_AFTER_DOC_ELEMENT',
|
||||
XML_ERROR_PARAM_ENTITY_REF => 'XML_ERROR_PARAM_ENTITY_REF',
|
||||
XML_ERROR_UNDEFINED_ENTITY => 'XML_ERROR_UNDEFINED_ENTITY',
|
||||
XML_ERROR_RECURSIVE_ENTITY_REF => 'XML_ERROR_RECURSIVE_ENTITY_REF',
|
||||
XML_ERROR_ASYNC_ENTITY => 'XML_ERROR_ASYNC_ENTITY',
|
||||
XML_ERROR_BAD_CHAR_REF => 'XML_ERROR_BAD_CHAR_REF',
|
||||
XML_ERROR_BINARY_ENTITY_REF => 'XML_ERROR_BINARY_ENTITY_REF',
|
||||
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF => 'XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF',
|
||||
XML_ERROR_MISPLACED_XML_PI => 'XML_ERROR_MISPLACED_XML_PI',
|
||||
XML_ERROR_UNKNOWN_ENCODING => 'XML_ERROR_UNKNOWN_ENCODING',
|
||||
XML_ERROR_INCORRECT_ENCODING => 'XML_ERROR_INCORRECT_ENCODING',
|
||||
XML_ERROR_UNCLOSED_CDATA_SECTION => 'XML_ERROR_UNCLOSED_CDATA_SECTION',
|
||||
XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING',
|
||||
);
|
||||
|
||||
public static function castXml($h, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a['current_byte_index'] = xml_get_current_byte_index($h);
|
||||
$a['current_column_number'] = xml_get_current_column_number($h);
|
||||
$a['current_line_number'] = xml_get_current_line_number($h);
|
||||
$a['error_code'] = xml_get_error_code($h);
|
||||
|
||||
if (isset(self::$xmlErrors[$a['error_code']])) {
|
||||
$a['error_code'] = new ConstStub(self::$xmlErrors[$a['error_code']], $a['error_code']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\VarDumper\Cloner;
|
||||
|
||||
use Symfony\Component\VarDumper\Caster\Caster;
|
||||
use Symfony\Component\VarDumper\Exception\ThrowingCasterException;
|
||||
|
||||
/**
|
||||
@@ -22,10 +23,21 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
{
|
||||
public static $defaultCasters = array(
|
||||
'Symfony\Component\VarDumper\Caster\CutStub' => 'Symfony\Component\VarDumper\Caster\StubCaster::castStub',
|
||||
'Symfony\Component\VarDumper\Caster\CutArrayStub' => 'Symfony\Component\VarDumper\Caster\StubCaster::castCutArray',
|
||||
'Symfony\Component\VarDumper\Caster\ConstStub' => 'Symfony\Component\VarDumper\Caster\StubCaster::castStub',
|
||||
'Symfony\Component\VarDumper\Caster\EnumStub' => 'Symfony\Component\VarDumper\Caster\StubCaster::castEnum',
|
||||
|
||||
'Closure' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castClosure',
|
||||
'Reflector' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castReflector',
|
||||
'Generator' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castGenerator',
|
||||
'ReflectionType' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castType',
|
||||
'ReflectionGenerator' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castReflectionGenerator',
|
||||
'ReflectionClass' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castClass',
|
||||
'ReflectionFunctionAbstract' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castFunctionAbstract',
|
||||
'ReflectionMethod' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castMethod',
|
||||
'ReflectionParameter' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castParameter',
|
||||
'ReflectionProperty' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castProperty',
|
||||
'ReflectionExtension' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castExtension',
|
||||
'ReflectionZendExtension' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castZendExtension',
|
||||
|
||||
'Doctrine\Common\Persistence\ObjectManager' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||
'Doctrine\Common\Proxy\Proxy' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castCommonProxy',
|
||||
@@ -60,25 +72,47 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
'Error' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castError',
|
||||
'Symfony\Component\DependencyInjection\ContainerInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||
'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castThrowingCasterException',
|
||||
'Symfony\Component\VarDumper\Caster\TraceStub' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castTraceStub',
|
||||
'Symfony\Component\VarDumper\Caster\FrameStub' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castFrameStub',
|
||||
|
||||
'PHPUnit_Framework_MockObject_MockObject' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||
'Prophecy\Prophecy\ProphecySubjectInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||
'Mockery\MockInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||
|
||||
'PDO' => 'Symfony\Component\VarDumper\Caster\PdoCaster::castPdo',
|
||||
'PDOStatement' => 'Symfony\Component\VarDumper\Caster\PdoCaster::castPdoStatement',
|
||||
|
||||
'AMQPConnection' => 'Symfony\Component\VarDumper\Caster\AmqpCaster::castConnection',
|
||||
'AMQPChannel' => 'Symfony\Component\VarDumper\Caster\AmqpCaster::castChannel',
|
||||
'AMQPQueue' => 'Symfony\Component\VarDumper\Caster\AmqpCaster::castQueue',
|
||||
'AMQPExchange' => 'Symfony\Component\VarDumper\Caster\AmqpCaster::castExchange',
|
||||
'AMQPEnvelope' => 'Symfony\Component\VarDumper\Caster\AmqpCaster::castEnvelope',
|
||||
|
||||
'ArrayObject' => 'Symfony\Component\VarDumper\Caster\SplCaster::castArrayObject',
|
||||
'SplDoublyLinkedList' => 'Symfony\Component\VarDumper\Caster\SplCaster::castDoublyLinkedList',
|
||||
'SplFileInfo' => 'Symfony\Component\VarDumper\Caster\SplCaster::castFileInfo',
|
||||
'SplFileObject' => 'Symfony\Component\VarDumper\Caster\SplCaster::castFileObject',
|
||||
'SplFixedArray' => 'Symfony\Component\VarDumper\Caster\SplCaster::castFixedArray',
|
||||
'SplHeap' => 'Symfony\Component\VarDumper\Caster\SplCaster::castHeap',
|
||||
'SplObjectStorage' => 'Symfony\Component\VarDumper\Caster\SplCaster::castObjectStorage',
|
||||
'SplPriorityQueue' => 'Symfony\Component\VarDumper\Caster\SplCaster::castHeap',
|
||||
'OuterIterator' => 'Symfony\Component\VarDumper\Caster\SplCaster::castOuterIterator',
|
||||
|
||||
'MongoCursorInterface' => 'Symfony\Component\VarDumper\Caster\MongoCaster::castCursor',
|
||||
|
||||
':curl' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castCurl',
|
||||
':dba' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castDba',
|
||||
':dba persistent' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castDba',
|
||||
':gd' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castGd',
|
||||
':mysql link' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castMysqlLink',
|
||||
':pgsql large object' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castLargeObject',
|
||||
':pgsql link' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castLink',
|
||||
':pgsql link persistent' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castLink',
|
||||
':pgsql result' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castResult',
|
||||
':process' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castProcess',
|
||||
':stream' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castStream',
|
||||
':stream-context' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castStreamContext',
|
||||
':xml' => 'Symfony\Component\VarDumper\Caster\XmlResourceCaster::castXml',
|
||||
);
|
||||
|
||||
protected $maxItems = 2500;
|
||||
@@ -88,6 +122,7 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
private $casters = array();
|
||||
private $prevErrorHandler;
|
||||
private $classInfo = array();
|
||||
private $filter = 0;
|
||||
|
||||
/**
|
||||
* @param callable[]|null $casters A map of casters.
|
||||
@@ -141,15 +176,30 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Clones a PHP variable.
|
||||
*
|
||||
* @param mixed $var Any PHP variable.
|
||||
* @param int $filter A bit field of Caster::EXCLUDE_* constants.
|
||||
*
|
||||
* @return Data The cloned variable represented by a Data object.
|
||||
*/
|
||||
public function cloneVar($var)
|
||||
public function cloneVar($var, $filter = 0)
|
||||
{
|
||||
$this->prevErrorHandler = set_error_handler(array($this, 'handleError'));
|
||||
try {
|
||||
if (!function_exists('iconv')) {
|
||||
$this->maxString = -1;
|
||||
$this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) {
|
||||
if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) {
|
||||
// Cloner never dies
|
||||
throw new \ErrorException($msg, 0, $type, $file, $line);
|
||||
}
|
||||
|
||||
if ($this->prevErrorHandler) {
|
||||
return call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
$this->filter = $filter;
|
||||
|
||||
try {
|
||||
$data = $this->doClone($var);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
@@ -185,37 +235,23 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
$obj = $stub->value;
|
||||
$class = $stub->class;
|
||||
|
||||
if (isset($class[15]) && "\0" === $class[15] && 0 === strpos($class, "class@anonymous\x00")) {
|
||||
$stub->class = get_parent_class($class).'@anonymous';
|
||||
}
|
||||
if (isset($this->classInfo[$class])) {
|
||||
$classInfo = $this->classInfo[$class];
|
||||
$stub->class = $classInfo[0];
|
||||
} else {
|
||||
$classInfo = array(
|
||||
$class,
|
||||
method_exists($class, '__debugInfo'),
|
||||
new \ReflectionClass($class),
|
||||
array_reverse(array($class => $class) + class_parents($class) + class_implements($class)),
|
||||
array_reverse(array($class => $class) + class_parents($class) + class_implements($class) + array('*' => '*')),
|
||||
);
|
||||
|
||||
$this->classInfo[$class] = $classInfo;
|
||||
}
|
||||
|
||||
if ($classInfo[1]) {
|
||||
$a = $this->callCaster(function ($obj) {return $obj->__debugInfo();}, $obj, array(), null, $isNested);
|
||||
} else {
|
||||
$a = (array) $obj;
|
||||
}
|
||||
$a = $this->callCaster('Symfony\Component\VarDumper\Caster\Caster::castObject', $obj, $classInfo[0], null, $isNested);
|
||||
|
||||
if ($a) {
|
||||
$p = array_keys($a);
|
||||
foreach ($p as $i => $k) {
|
||||
if (!isset($k[0]) || ("\0" !== $k[0] && !$classInfo[2]->hasProperty($k))) {
|
||||
$p[$i] = "\0+\0".$k;
|
||||
}
|
||||
}
|
||||
$a = array_combine($p, $a);
|
||||
}
|
||||
|
||||
foreach ($classInfo[3] as $p) {
|
||||
foreach ($classInfo[1] as $p) {
|
||||
if (!empty($this->casters[$p = strtolower($p)])) {
|
||||
foreach ($this->casters[$p] as $p) {
|
||||
$a = $this->callCaster($p, $obj, $a, $stub, $isNested);
|
||||
@@ -263,34 +299,15 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
private function callCaster($callback, $obj, $a, $stub, $isNested)
|
||||
{
|
||||
try {
|
||||
$cast = call_user_func($callback, $obj, $a, $stub, $isNested);
|
||||
$cast = call_user_func($callback, $obj, $a, $stub, $isNested, $this->filter);
|
||||
|
||||
if (is_array($cast)) {
|
||||
$a = $cast;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$a[(Stub::TYPE_OBJECT === $stub->type ? "\0~\0" : '').'⚠'] = new ThrowingCasterException($callback, $e);
|
||||
$a[(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠'] = new ThrowingCasterException($e);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special handling for errors: cloning must be fail-safe.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function handleError($type, $msg, $file, $line, $context)
|
||||
{
|
||||
if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) {
|
||||
// Cloner never dies
|
||||
throw new \ErrorException($msg, 0, $type, $file, $line);
|
||||
}
|
||||
|
||||
if ($this->prevErrorHandler) {
|
||||
return call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -40,17 +40,43 @@ class Data
|
||||
/**
|
||||
* Returns a depth limited clone of $this.
|
||||
*
|
||||
* @param int $maxDepth The max dumped depth level.
|
||||
* @param int $maxItemsPerDepth The max number of items dumped per depth level.
|
||||
* @param bool $useRefHandles False to hide ref. handles.
|
||||
* @param int $maxDepth The max dumped depth level.
|
||||
*
|
||||
* @return self A depth limited clone of $this.
|
||||
* @return self A clone of $this.
|
||||
*/
|
||||
public function getLimitedClone($maxDepth, $maxItemsPerDepth, $useRefHandles = true)
|
||||
public function withMaxDepth($maxDepth)
|
||||
{
|
||||
$data = clone $this;
|
||||
$data->maxDepth = (int) $maxDepth;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limits the number of elements per depth level.
|
||||
*
|
||||
* @param int $maxItemsPerDepth The max number of items dumped per depth level.
|
||||
*
|
||||
* @return self A clone of $this.
|
||||
*/
|
||||
public function withMaxItemsPerDepth($maxItemsPerDepth)
|
||||
{
|
||||
$data = clone $this;
|
||||
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables objects' identifiers tracking.
|
||||
*
|
||||
* @param bool $useRefHandles False to hide global ref. handles.
|
||||
*
|
||||
* @return self A clone of $this.
|
||||
*/
|
||||
public function withRefHandles($useRefHandles)
|
||||
{
|
||||
$data = clone $this;
|
||||
$data->useRefHandles = $useRefHandles ? -1 : 0;
|
||||
|
||||
return $data;
|
||||
@@ -127,16 +153,20 @@ class Data
|
||||
break;
|
||||
|
||||
case Stub::TYPE_ARRAY:
|
||||
$dumper->enterHash($cursor, $item->class, $item->value, (bool) $children);
|
||||
$cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->class);
|
||||
$dumper->leaveHash($cursor, $item->class, $item->value, (bool) $children, $cut);
|
||||
break;
|
||||
|
||||
$item = clone $item;
|
||||
$item->type = $item->class;
|
||||
$item->class = $item->value;
|
||||
// No break;
|
||||
case Stub::TYPE_OBJECT:
|
||||
case Stub::TYPE_RESOURCE:
|
||||
$dumper->enterHash($cursor, $item->type, $item->class, (bool) $children);
|
||||
$cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->type);
|
||||
$dumper->leaveHash($cursor, $item->type, $item->class, (bool) $children, $cut);
|
||||
$withChildren = $children && $cursor->depth !== $this->maxDepth && $this->maxItemsPerDepth;
|
||||
$dumper->enterHash($cursor, $item->type, $item->class, $withChildren);
|
||||
if ($withChildren) {
|
||||
$cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->type);
|
||||
} elseif ($children && 0 <= $cut) {
|
||||
$cut += count($children);
|
||||
}
|
||||
$dumper->leaveHash($cursor, $item->type, $item->class, $withChildren, $cut);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -166,26 +196,20 @@ class Data
|
||||
*/
|
||||
private function dumpChildren($dumper, $parentCursor, &$refs, $children, $hashCut, $hashType)
|
||||
{
|
||||
if ($children) {
|
||||
if ($parentCursor->depth !== $this->maxDepth && $this->maxItemsPerDepth) {
|
||||
$cursor = clone $parentCursor;
|
||||
++$cursor->depth;
|
||||
$cursor->hashType = $hashType;
|
||||
$cursor->hashIndex = 0;
|
||||
$cursor->hashLength = count($children);
|
||||
$cursor->hashCut = $hashCut;
|
||||
foreach ($children as $key => $child) {
|
||||
$cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key);
|
||||
$cursor->hashKey = $key;
|
||||
$this->dumpItem($dumper, $cursor, $refs, $child);
|
||||
if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) {
|
||||
$parentCursor->stop = true;
|
||||
$cursor = clone $parentCursor;
|
||||
++$cursor->depth;
|
||||
$cursor->hashType = $hashType;
|
||||
$cursor->hashIndex = 0;
|
||||
$cursor->hashLength = count($children);
|
||||
$cursor->hashCut = $hashCut;
|
||||
foreach ($children as $key => $child) {
|
||||
$cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key);
|
||||
$cursor->hashKey = $key;
|
||||
$this->dumpItem($dumper, $cursor, $refs, $child);
|
||||
if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) {
|
||||
$parentCursor->stop = true;
|
||||
|
||||
return $hashCut >= 0 ? $hashCut + $cursor->hashLength - $cursor->hashIndex : $hashCut;
|
||||
}
|
||||
}
|
||||
} elseif ($hashCut >= 0) {
|
||||
$hashCut += count($children);
|
||||
return $hashCut >= 0 ? $hashCut + $cursor->hashLength - $cursor->hashIndex : $hashCut;
|
||||
}
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ class VarCloner extends AbstractCloner
|
||||
$zval['type'] = gettype($v);
|
||||
}
|
||||
if ($zval['zval_isref']) {
|
||||
$queue[$i][$k] =& $stub; // Break hard references to make $queue completely
|
||||
$queue[$i][$k] = &$stub; // Break hard references to make $queue completely
|
||||
unset($stub); // independent from the original structure
|
||||
if (isset($hardRefs[$zval['zval_hash']])) {
|
||||
$queue[$i][$k] = $useExt ? ($v = $hardRefs[$zval['zval_hash']]) : ($step[$k] = $v);
|
||||
@@ -102,12 +102,12 @@ class VarCloner extends AbstractCloner
|
||||
} else {
|
||||
$stub->value = $v;
|
||||
}
|
||||
} elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = iconv_strlen($v, 'UTF-8') - $maxString) {
|
||||
} elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) {
|
||||
$stub = new Stub();
|
||||
$stub->type = Stub::TYPE_STRING;
|
||||
$stub->class = Stub::STRING_UTF8;
|
||||
$stub->cut = $cut;
|
||||
$stub->value = iconv_substr($v, 0, $maxString, 'UTF-8');
|
||||
$stub->value = mb_substr($v, 0, $maxString, 'UTF-8');
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -130,7 +130,7 @@ class VarCloner extends AbstractCloner
|
||||
unset($v[$gid]);
|
||||
$a = array();
|
||||
foreach ($v as $gk => &$gv) {
|
||||
$a[$gk] =& $gv;
|
||||
$a[$gk] = &$gv;
|
||||
}
|
||||
} else {
|
||||
$a = $v;
|
||||
@@ -149,7 +149,7 @@ class VarCloner extends AbstractCloner
|
||||
$stub->handle = $h;
|
||||
$a = $this->castObject($stub, 0 < $i);
|
||||
if ($v !== $stub->value) {
|
||||
if (Stub::TYPE_OBJECT !== $stub->type) {
|
||||
if (Stub::TYPE_OBJECT !== $stub->type || null === $stub->value) {
|
||||
break;
|
||||
}
|
||||
if ($useExt) {
|
||||
@@ -210,7 +210,7 @@ class VarCloner extends AbstractCloner
|
||||
$step[$k] = new Stub();
|
||||
$step[$k]->value = $stub;
|
||||
$h = spl_object_hash($step[$k]);
|
||||
$queue[$i][$k] = $hardRefs[$h] =& $step[$k];
|
||||
$queue[$i][$k] = $hardRefs[$h] = &$step[$k];
|
||||
$values[$h] = $v;
|
||||
}
|
||||
$queue[$i][$k]->handle = ++$refs;
|
||||
@@ -249,7 +249,7 @@ class VarCloner extends AbstractCloner
|
||||
$step[$k] = $queue[$i][$k] = new Stub();
|
||||
$step[$k]->value = $v;
|
||||
$h = spl_object_hash($step[$k]);
|
||||
$hardRefs[$h] =& $step[$k];
|
||||
$hardRefs[$h] = &$step[$k];
|
||||
$values[$h] = $v;
|
||||
}
|
||||
$queue[$i][$k]->handle = ++$refs;
|
||||
@@ -282,7 +282,7 @@ class VarCloner extends AbstractCloner
|
||||
} else {
|
||||
// check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below
|
||||
$obFuncs = array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush');
|
||||
foreach (debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) {
|
||||
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
|
||||
if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], $obFuncs)) {
|
||||
$frame['line'] = 0;
|
||||
break;
|
@@ -30,7 +30,6 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
protected $indentPad = ' ';
|
||||
|
||||
private $charset;
|
||||
private $charsetConverter;
|
||||
|
||||
/**
|
||||
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput.
|
||||
@@ -82,29 +81,11 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$prev = $this->charset;
|
||||
$this->charsetConverter = 'fallback';
|
||||
|
||||
$charset = strtoupper($charset);
|
||||
$charset = null === $charset || 'UTF-8' === $charset || 'UTF8' === $charset ? 'CP1252' : $charset;
|
||||
|
||||
$supported = true;
|
||||
set_error_handler(function () use (&$supported) {$supported = false;});
|
||||
|
||||
if (function_exists('mb_encoding_aliases') && mb_encoding_aliases($charset)) {
|
||||
$this->charset = $charset;
|
||||
$this->charsetConverter = 'mbstring';
|
||||
} elseif (function_exists('iconv')) {
|
||||
$supported = true;
|
||||
iconv($charset, 'UTF-8', '');
|
||||
if ($supported) {
|
||||
$this->charset = $charset;
|
||||
$this->charsetConverter = 'iconv';
|
||||
}
|
||||
}
|
||||
if ('fallback' === $this->charsetConverter) {
|
||||
$this->charset = 'ISO-8859-1';
|
||||
}
|
||||
restore_error_handler();
|
||||
$this->charset = $charset;
|
||||
|
||||
return $prev;
|
||||
}
|
||||
@@ -141,6 +122,8 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
$this->dumpLine(-1);
|
||||
} catch (\Exception $exception) {
|
||||
// Re-thrown below
|
||||
} catch (\Throwable $exception) {
|
||||
// Re-thrown below
|
||||
}
|
||||
if ($output) {
|
||||
$this->setOutput($prevOutput);
|
||||
@@ -183,40 +166,13 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
*/
|
||||
protected function utf8Encode($s)
|
||||
{
|
||||
if ('mbstring' === $this->charsetConverter) {
|
||||
return mb_convert_encoding($s, 'UTF-8', mb_check_encoding($s, $this->charset) ? $this->charset : '8bit');
|
||||
if (false !== $c = @iconv($this->charset, 'UTF-8', $s)) {
|
||||
return $c;
|
||||
}
|
||||
if ('iconv' === $this->charsetConverter) {
|
||||
$valid = true;
|
||||
set_error_handler(function () use (&$valid) {$valid = false;});
|
||||
$c = iconv($this->charset, 'UTF-8', $s);
|
||||
restore_error_handler();
|
||||
if ($valid) {
|
||||
return $c;
|
||||
}
|
||||
if ('CP1252' !== $this->charset && false !== $c = @iconv('CP1252', 'UTF-8', $s)) {
|
||||
return $c;
|
||||
}
|
||||
|
||||
$s .= $s;
|
||||
$len = strlen($s);
|
||||
|
||||
for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
|
||||
switch (true) {
|
||||
case $s[$i] < "\x80":
|
||||
$s[$j] = $s[$i];
|
||||
break;
|
||||
|
||||
case $s[$i] < "\xC0":
|
||||
$s[$j] = "\xC2";
|
||||
$s[++$j] = $s[$i];
|
||||
break;
|
||||
|
||||
default:
|
||||
$s[$j] = "\xC3";
|
||||
$s[++$j] = chr(ord($s[$i]) - 64);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return substr($s, 0, $j);
|
||||
return iconv('CP850', 'UTF-8', $s);
|
||||
}
|
||||
}
|
@@ -58,8 +58,8 @@ class CliDumper extends AbstractDumper
|
||||
{
|
||||
parent::__construct($output, $charset);
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR && false !== @getenv('ANSICON')) {
|
||||
// Use only the base 16 xterm colors when using ANSICON
|
||||
if ('\\' === DIRECTORY_SEPARATOR && 'ON' !== @getenv('ConEmuANSI') && 'xterm' !== @getenv('TERM')) {
|
||||
// Use only the base 16 xterm colors when using ANSICON or standard Windows 10 CLI
|
||||
$this->setStyles(array(
|
||||
'default' => '31',
|
||||
'num' => '1;34',
|
||||
@@ -91,9 +91,7 @@ class CliDumper extends AbstractDumper
|
||||
*/
|
||||
public function setMaxStringWidth($maxStringWidth)
|
||||
{
|
||||
if (function_exists('iconv')) {
|
||||
$this->maxStringWidth = (int) $maxStringWidth;
|
||||
}
|
||||
$this->maxStringWidth = (int) $maxStringWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +169,7 @@ class CliDumper extends AbstractDumper
|
||||
$this->dumpLine($cursor->depth, true);
|
||||
} else {
|
||||
$attr = array(
|
||||
'length' => 0 <= $cut && function_exists('iconv_strlen') ? iconv_strlen($str, 'UTF-8') + $cut : 0,
|
||||
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
|
||||
'binary' => $bin,
|
||||
);
|
||||
$str = explode("\n", $str);
|
||||
@@ -197,8 +195,8 @@ class CliDumper extends AbstractDumper
|
||||
if ($i < $m) {
|
||||
$str .= "\n";
|
||||
}
|
||||
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = iconv_strlen($str, 'UTF-8')) {
|
||||
$str = iconv_substr($str, 0, $this->maxStringWidth, 'UTF-8');
|
||||
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) {
|
||||
$str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8');
|
||||
$lineCut = $len - $this->maxStringWidth;
|
||||
}
|
||||
if ($m && 0 < $cursor->depth) {
|
||||
@@ -247,7 +245,7 @@ class CliDumper extends AbstractDumper
|
||||
$class = $this->utf8Encode($class);
|
||||
}
|
||||
if (Cursor::HASH_OBJECT === $type) {
|
||||
$prefix = 'stdClass' !== $class ? $this->style('note', $class).' {' : '{';
|
||||
$prefix = $class && 'stdClass' !== $class ? $this->style('note', $class).' {' : '{';
|
||||
} elseif (Cursor::HASH_RESOURCE === $type) {
|
||||
$prefix = $this->style('note', $class.' resource').($hasChild ? ' {' : ' ');
|
||||
} else {
|
||||
@@ -448,7 +446,12 @@ class CliDumper extends AbstractDumper
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
static::$defaultColors = @(false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'));
|
||||
static::$defaultColors = @(
|
||||
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
|
||||
|| false !== getenv('ANSICON')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM')
|
||||
);
|
||||
} elseif (function_exists('posix_isatty')) {
|
||||
$h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null);
|
||||
$h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'wb') : $this->outputStream;
|
@@ -31,7 +31,7 @@ class HtmlDumper extends CliDumper
|
||||
protected $headerIsDumped = false;
|
||||
protected $lastDepth = -1;
|
||||
protected $styles = array(
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000',
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: normal',
|
||||
'num' => 'font-weight:bold; color:#1299DA',
|
||||
'const' => 'font-weight:bold',
|
||||
'str' => 'font-weight:bold; color:#56DB3A',
|
||||
@@ -50,7 +50,7 @@ class HtmlDumper extends CliDumper
|
||||
*/
|
||||
public function __construct($output = null, $charset = null)
|
||||
{
|
||||
parent::__construct($output, $charset);
|
||||
AbstractDumper::__construct($output, $charset);
|
||||
$this->dumpId = 'sf-dump-'.mt_rand();
|
||||
}
|
||||
|
||||
@@ -123,23 +123,53 @@ Sfdump = window.Sfdump || (function (doc) {
|
||||
|
||||
var refStyle = doc.createElement('style'),
|
||||
rxEsc = /([.*+?^${}()|\[\]\/\\])/g,
|
||||
idRx = /\bsf-dump-\d+-ref[012]\w+\b/;
|
||||
idRx = /\bsf-dump-\d+-ref[012]\w+\b/,
|
||||
keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl',
|
||||
addEventListener = function (e, n, cb) {
|
||||
e.addEventListener(n, cb, false);
|
||||
};
|
||||
|
||||
doc.documentElement.firstChild.appendChild(refStyle);
|
||||
(doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle);
|
||||
|
||||
function toggle(a) {
|
||||
var s = a.nextSibling || {};
|
||||
if (!doc.addEventListener) {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.attachEvent('on' + eventName, function (e) {
|
||||
e.preventDefault = function () {e.returnValue = false;};
|
||||
e.target = e.srcElement;
|
||||
callback(e);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
if ('sf-dump-compact' == s.className) {
|
||||
a.lastChild.innerHTML = '▼';
|
||||
s.className = 'sf-dump-expanded';
|
||||
} else if ('sf-dump-expanded' == s.className) {
|
||||
a.lastChild.innerHTML = '▶';
|
||||
s.className = 'sf-dump-compact';
|
||||
function toggle(a, recursive) {
|
||||
var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass;
|
||||
|
||||
if ('sf-dump-compact' == oldClass) {
|
||||
arrow = '▼';
|
||||
newClass = 'sf-dump-expanded';
|
||||
} else if ('sf-dump-expanded' == oldClass) {
|
||||
arrow = '▶';
|
||||
newClass = 'sf-dump-compact';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
a.lastChild.innerHTML = arrow;
|
||||
s.className = newClass;
|
||||
|
||||
if (recursive) {
|
||||
try {
|
||||
a = s.querySelectorAll('.'+oldClass);
|
||||
for (s = 0; s < a.length; ++s) {
|
||||
if (a[s].className !== newClass) {
|
||||
a[s].className = newClass;
|
||||
a[s].previousSibling.lastChild.innerHTML = arrow;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -147,7 +177,7 @@ return function (root) {
|
||||
root = doc.getElementById(root);
|
||||
|
||||
function a(e, f) {
|
||||
root.addEventListener(e, function (e) {
|
||||
addEventListener(root, e, function (e) {
|
||||
if ('A' == e.target.tagName) {
|
||||
f(e.target, e);
|
||||
} else if ('A' == e.target.parentNode.tagName) {
|
||||
@@ -155,20 +185,26 @@ return function (root) {
|
||||
}
|
||||
});
|
||||
};
|
||||
root.addEventListener('mouseover', function (e) {
|
||||
function isCtrlKey(e) {
|
||||
return e.ctrlKey || e.metaKey;
|
||||
}
|
||||
addEventListener(root, 'mouseover', function (e) {
|
||||
if ('' != refStyle.innerHTML) {
|
||||
refStyle.innerHTML = '';
|
||||
}
|
||||
});
|
||||
a('mouseover', function (a) {
|
||||
if (a = idRx.exec(a.className)) {
|
||||
refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}';
|
||||
try {
|
||||
refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}';
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
a('click', function (a, e) {
|
||||
if (/\bsf-dump-toggle\b/.test(a.className)) {
|
||||
e.preventDefault();
|
||||
if (!toggle(a)) {
|
||||
if (!toggle(a, isCtrlKey(e))) {
|
||||
var r = doc.getElementById(a.getAttribute('href').substr(1)),
|
||||
s = r.previousSibling,
|
||||
f = r.parentNode,
|
||||
@@ -182,9 +218,19 @@ return function (root) {
|
||||
r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\\$1'), 'mg'), t[0]);
|
||||
}
|
||||
if ('sf-dump-compact' == r.className) {
|
||||
toggle(s);
|
||||
toggle(s, isCtrlKey(e));
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.getSelection) {
|
||||
try {
|
||||
doc.getSelection().removeAllRanges();
|
||||
} catch (e) {
|
||||
doc.getSelection().empty();
|
||||
}
|
||||
} else {
|
||||
doc.selection.empty();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -218,6 +264,7 @@ return function (root) {
|
||||
} else {
|
||||
a.innerHTML += ' ';
|
||||
}
|
||||
a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children';
|
||||
a.innerHTML += '<span>▼</span>';
|
||||
a.className += ' sf-dump-toggle';
|
||||
if ('sf-dump' != elt.parentNode.className) {
|
||||
@@ -395,30 +442,7 @@ EOHTML;
|
||||
}
|
||||
$this->lastDepth = $depth;
|
||||
|
||||
// Replaces non-ASCII UTF-8 chars by numeric HTML entities
|
||||
$this->line = preg_replace_callback(
|
||||
'/[\x80-\xFF]+/',
|
||||
function ($m) {
|
||||
$m = unpack('C*', $m[0]);
|
||||
$i = 1;
|
||||
$entities = '';
|
||||
|
||||
while (isset($m[$i])) {
|
||||
if (0xF0 <= $m[$i]) {
|
||||
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
||||
} elseif (0xE0 <= $m[$i]) {
|
||||
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
||||
} else {
|
||||
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
|
||||
}
|
||||
|
||||
$entities .= '&#'.$c.';';
|
||||
}
|
||||
|
||||
return $entities;
|
||||
},
|
||||
$this->line
|
||||
);
|
||||
$this->line = mb_convert_encoding($this->line, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
if (-1 === $depth) {
|
||||
AbstractDumper::dumpLine(0);
|
26
vendor/symfony/var-dumper/Exception/ThrowingCasterException.php
vendored
Normal file
26
vendor/symfony/var-dumper/Exception/ThrowingCasterException.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Exception;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ThrowingCasterException extends \Exception
|
||||
{
|
||||
/**
|
||||
* @param \Exception $prev The exception thrown from the caster
|
||||
*/
|
||||
public function __construct(\Exception $prev)
|
||||
{
|
||||
parent::__construct('Unexpected '.get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev);
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2014-2015 Fabien Potencier
|
||||
Copyright (c) 2014-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
15
vendor/symfony/var-dumper/README.md
vendored
Normal file
15
vendor/symfony/var-dumper/README.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
VarDumper Component
|
||||
===================
|
||||
|
||||
The VarDumper component provides mechanisms for walking through any arbitrary
|
||||
PHP variable. Built on top, it provides a better `dump()` function that you
|
||||
can use instead of `var_dump`.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/var_dumper/introduction.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Exception\ThrowingCasterException;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts common Exception classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ExceptionCaster
|
||||
{
|
||||
public static $traceArgs = true;
|
||||
public static $errorTypes = array(
|
||||
E_DEPRECATED => 'E_DEPRECATED',
|
||||
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
|
||||
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
|
||||
E_ERROR => 'E_ERROR',
|
||||
E_WARNING => 'E_WARNING',
|
||||
E_PARSE => 'E_PARSE',
|
||||
E_NOTICE => 'E_NOTICE',
|
||||
E_CORE_ERROR => 'E_CORE_ERROR',
|
||||
E_CORE_WARNING => 'E_CORE_WARNING',
|
||||
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
|
||||
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
|
||||
E_USER_ERROR => 'E_USER_ERROR',
|
||||
E_USER_WARNING => 'E_USER_WARNING',
|
||||
E_USER_NOTICE => 'E_USER_NOTICE',
|
||||
E_STRICT => 'E_STRICT',
|
||||
);
|
||||
|
||||
public static function castError(\Error $e, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
return $e instanceof \Exception ? $a : self::filterExceptionArray($a, "\0Error\0");
|
||||
}
|
||||
|
||||
public static function castException(\Exception $e, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
return self::filterExceptionArray($a, "\0Exception\0");
|
||||
}
|
||||
|
||||
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if (isset($a[$s = "\0*\0severity"], self::$errorTypes[$a[$s]])) {
|
||||
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = "\0*\0";
|
||||
$xPrefix = "\0Exception\0";
|
||||
|
||||
if (isset($a[$xPrefix.'previous'], $a[$xPrefix.'trace'][0])) {
|
||||
$b = (array) $a[$xPrefix.'previous'];
|
||||
$b[$xPrefix.'trace'][0] += array(
|
||||
'file' => $b[$prefix.'file'],
|
||||
'line' => $b[$prefix.'line'],
|
||||
);
|
||||
array_splice($b[$xPrefix.'trace'], -1 - count($a[$xPrefix.'trace']));
|
||||
static::filterTrace($b[$xPrefix.'trace'], false);
|
||||
$a["\0~\0trace"] = $b[$xPrefix.'trace'];
|
||||
}
|
||||
|
||||
unset($a[$xPrefix.'trace'], $a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function filterTrace(&$trace, $dumpArgs, $offset = 0)
|
||||
{
|
||||
if (0 > $offset || empty($trace[$offset])) {
|
||||
return $trace = null;
|
||||
}
|
||||
|
||||
$t = $trace[$offset];
|
||||
|
||||
if (empty($t['class']) && isset($t['function'])) {
|
||||
if ('user_error' === $t['function'] || 'trigger_error' === $t['function']) {
|
||||
++$offset;
|
||||
}
|
||||
}
|
||||
|
||||
if ($offset) {
|
||||
array_splice($trace, 0, $offset);
|
||||
}
|
||||
|
||||
foreach ($trace as &$t) {
|
||||
$t = array(
|
||||
'call' => (isset($t['class']) ? $t['class'].$t['type'] : '').$t['function'].'()',
|
||||
'file' => isset($t['line']) ? "{$t['file']}:{$t['line']}" : '',
|
||||
'args' => &$t['args'],
|
||||
);
|
||||
|
||||
if (!isset($t['args']) || !$dumpArgs) {
|
||||
unset($t['args']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function filterExceptionArray(array $a, $xPrefix)
|
||||
{
|
||||
if (isset($a[$xPrefix.'trace'])) {
|
||||
$trace = $a[$xPrefix.'trace'];
|
||||
unset($a[$xPrefix.'trace']); // Ensures the trace is always last
|
||||
} else {
|
||||
$trace = array();
|
||||
}
|
||||
|
||||
static::filterTrace($trace, static::$traceArgs);
|
||||
|
||||
if (null !== $trace) {
|
||||
$a[$xPrefix.'trace'] = $trace;
|
||||
}
|
||||
if (empty($a[$xPrefix.'previous'])) {
|
||||
unset($a[$xPrefix.'previous']);
|
||||
}
|
||||
unset($a[$xPrefix.'string'], $a["\0+\0xdebug_message"], $a["\0+\0__destructorException"]);
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Reflector related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ReflectionCaster
|
||||
{
|
||||
public static function castReflector(\Reflector $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a["\0~\0reflection"] = $c->__toString();
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$stub->class = 'Closure'; // HHVM generates unique class names for closures
|
||||
$a = static::castReflector(new \ReflectionFunction($c), $a, $stub, $isNested);
|
||||
unset($a["\0+\0000"], $a['name'], $a["\0+\0this"], $a["\0+\0parameter"]);
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts SPL related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class SplCaster
|
||||
{
|
||||
public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = "\0~\0";
|
||||
$class = $stub->class;
|
||||
$flags = $c->getFlags();
|
||||
|
||||
$b = array(
|
||||
$prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
|
||||
$prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
|
||||
$prefix.'iteratorClass' => $c->getIteratorClass(),
|
||||
$prefix.'storage' => $c->getArrayCopy(),
|
||||
);
|
||||
|
||||
if ($class === 'ArrayObject') {
|
||||
$a = $b;
|
||||
} else {
|
||||
if (!($flags & \ArrayObject::STD_PROP_LIST)) {
|
||||
$c->setFlags(\ArrayObject::STD_PROP_LIST);
|
||||
|
||||
if ($a = (array) $c) {
|
||||
$class = new \ReflectionClass($class);
|
||||
foreach ($a as $k => $p) {
|
||||
if (!isset($k[0]) || ("\0" !== $k[0] && !$class->hasProperty($k))) {
|
||||
unset($a[$k]);
|
||||
$a["\0+\0".$k] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$c->setFlags($flags);
|
||||
}
|
||||
|
||||
$a += $b;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castHeap(\Iterator $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a += array(
|
||||
"\0~\0heap" => iterator_to_array(clone $c),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$prefix = "\0~\0";
|
||||
$mode = $c->getIteratorMode();
|
||||
$c->setIteratorMode(\SplDoublyLinkedList::IT_MODE_KEEP | $mode & ~\SplDoublyLinkedList::IT_MODE_DELETE);
|
||||
|
||||
$a += array(
|
||||
$prefix.'mode' => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_KEEP) ? 'IT_MODE_KEEP' : 'IT_MODE_DELETE'), $mode),
|
||||
$prefix.'dllist' => iterator_to_array($c),
|
||||
);
|
||||
$c->setIteratorMode($mode);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a += array(
|
||||
"\0~\0storage" => $c->toArray(),
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$storage = array();
|
||||
unset($a["\0+\0\0gcdata"]); // Don't hit https://bugs.php.net/65967
|
||||
|
||||
foreach ($c as $obj) {
|
||||
$storage[spl_object_hash($obj)] = array(
|
||||
'object' => $obj,
|
||||
'info' => $c->getInfo(),
|
||||
);
|
||||
}
|
||||
|
||||
$a += array(
|
||||
"\0~\0storage" => $storage,
|
||||
);
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Exception;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ThrowingCasterException extends \Exception
|
||||
{
|
||||
/**
|
||||
* @param callable $caster The failing caster
|
||||
* @param \Exception $prev The exception thrown from the caster
|
||||
*/
|
||||
public function __construct($caster, \Exception $prev)
|
||||
{
|
||||
parent::__construct('Unexpected '.get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev);
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
Symfony mechanism for exploring and dumping PHP variables
|
||||
=========================================================
|
||||
|
||||
This component provides a mechanism that allows exploring then dumping
|
||||
any PHP variable.
|
||||
|
||||
It handles scalars, objects and resources properly, taking hard and soft
|
||||
references into account. More than being immune to infinite recursion
|
||||
problems, it allows dumping where references link to each other.
|
||||
It explores recursive structures using a breadth-first algorithm.
|
||||
|
||||
The component exposes all the parts involved in the different steps of
|
||||
cloning then dumping a PHP variable, while applying size limits and having
|
||||
specialized output formats and methods.
|
45
vendor/symfony/var-dumper/Test/VarDumperTestTrait.php
vendored
Normal file
45
vendor/symfony/var-dumper/Test/VarDumperTestTrait.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Test;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
trait VarDumperTestTrait
|
||||
{
|
||||
public function assertDumpEquals($dump, $data, $message = '')
|
||||
{
|
||||
$this->assertSame(rtrim($dump), $this->getDump($data), $message);
|
||||
}
|
||||
|
||||
public function assertDumpMatchesFormat($dump, $data, $message = '')
|
||||
{
|
||||
$this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message);
|
||||
}
|
||||
|
||||
protected function getDump($data)
|
||||
{
|
||||
$h = fopen('php://memory', 'r+b');
|
||||
$cloner = new VarCloner();
|
||||
$cloner->setMaxItems(-1);
|
||||
$dumper = new CliDumper($h);
|
||||
$dumper->setColors(false);
|
||||
$dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
|
||||
$data = stream_get_contents($h, -1, 0);
|
||||
fclose($h);
|
||||
|
||||
return rtrim($data);
|
||||
}
|
||||
}
|
180
vendor/symfony/var-dumper/Tests/Caster/CasterTest.php
vendored
Normal file
180
vendor/symfony/var-dumper/Tests/Caster/CasterTest.php
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Caster\Caster;
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CasterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
private $referenceArray = array(
|
||||
'null' => null,
|
||||
'empty' => false,
|
||||
'public' => 'pub',
|
||||
"\0~\0virtual" => 'virt',
|
||||
"\0+\0dynamic" => 'dyn',
|
||||
"\0*\0protected" => 'prot',
|
||||
"\0Foo\0private" => 'priv',
|
||||
);
|
||||
|
||||
/**
|
||||
* @dataProvider provideFilter
|
||||
*/
|
||||
public function testFilter($filter, $expectedDiff, $listedProperties = null)
|
||||
{
|
||||
if (null === $listedProperties) {
|
||||
$filteredArray = Caster::filter($this->referenceArray, $filter);
|
||||
} else {
|
||||
$filteredArray = Caster::filter($this->referenceArray, $filter, $listedProperties);
|
||||
}
|
||||
|
||||
$this->assertSame($expectedDiff, array_diff_assoc($this->referenceArray, $filteredArray));
|
||||
}
|
||||
|
||||
public function provideFilter()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
0,
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_PUBLIC,
|
||||
array(
|
||||
'null' => null,
|
||||
'empty' => false,
|
||||
'public' => 'pub',
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_NULL,
|
||||
array(
|
||||
'null' => null,
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_EMPTY,
|
||||
array(
|
||||
'null' => null,
|
||||
'empty' => false,
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_VIRTUAL,
|
||||
array(
|
||||
"\0~\0virtual" => 'virt',
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_DYNAMIC,
|
||||
array(
|
||||
"\0+\0dynamic" => 'dyn',
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_PROTECTED,
|
||||
array(
|
||||
"\0*\0protected" => 'prot',
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_PRIVATE,
|
||||
array(
|
||||
"\0Foo\0private" => 'priv',
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_VERBOSE,
|
||||
array(
|
||||
'public' => 'pub',
|
||||
"\0*\0protected" => 'prot',
|
||||
),
|
||||
array('public', "\0*\0protected"),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_NOT_IMPORTANT,
|
||||
array(
|
||||
'null' => null,
|
||||
'empty' => false,
|
||||
"\0~\0virtual" => 'virt',
|
||||
"\0+\0dynamic" => 'dyn',
|
||||
"\0Foo\0private" => 'priv',
|
||||
),
|
||||
array('public', "\0*\0protected"),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_VIRTUAL | Caster::EXCLUDE_DYNAMIC,
|
||||
array(
|
||||
"\0~\0virtual" => 'virt',
|
||||
"\0+\0dynamic" => 'dyn',
|
||||
),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_NOT_IMPORTANT | Caster::EXCLUDE_VERBOSE,
|
||||
$this->referenceArray,
|
||||
array('public', "\0*\0protected"),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_NOT_IMPORTANT | Caster::EXCLUDE_EMPTY,
|
||||
array(
|
||||
'null' => null,
|
||||
'empty' => false,
|
||||
"\0~\0virtual" => 'virt',
|
||||
"\0+\0dynamic" => 'dyn',
|
||||
"\0*\0protected" => 'prot',
|
||||
"\0Foo\0private" => 'priv',
|
||||
),
|
||||
array('public', 'empty'),
|
||||
),
|
||||
array(
|
||||
Caster::EXCLUDE_VERBOSE | Caster::EXCLUDE_EMPTY | Caster::EXCLUDE_STRICT,
|
||||
array(
|
||||
'empty' => false,
|
||||
),
|
||||
array('public', 'empty'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
public function testAnonymousClass()
|
||||
{
|
||||
$c = eval('return new class extends stdClass { private $foo = "foo"; };');
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
stdClass@anonymous {
|
||||
-foo: "foo"
|
||||
}
|
||||
EOTXT
|
||||
, $c
|
||||
);
|
||||
|
||||
$c = eval('return new class { private $foo = "foo"; };');
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
@anonymous {
|
||||
-foo: "foo"
|
||||
}
|
||||
EOTXT
|
||||
, $c
|
||||
);
|
||||
}
|
||||
}
|
@@ -19,18 +19,19 @@ use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
*/
|
||||
class PdoCasterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @requires extension pdo_sqlite
|
||||
*/
|
||||
public function testCastPdo()
|
||||
{
|
||||
if (!extension_loaded('pdo_sqlite')) {
|
||||
$this->markTestSkipped('pdo_sqlite extension is required');
|
||||
}
|
||||
|
||||
$pdo = new \PDO('sqlite::memory:');
|
||||
$pdo->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array($pdo)));
|
||||
|
||||
$cast = PdoCaster::castPdo($pdo, array(), new Stub(), false);
|
||||
$attr = $cast["\0~\0attributes"];
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\VarDumper\Caster\EnumStub', $cast["\0~\0attributes"]);
|
||||
|
||||
$attr = $cast["\0~\0attributes"] = $cast["\0~\0attributes"]->value;
|
||||
$this->assertInstanceOf('Symfony\Component\VarDumper\Caster\ConstStub', $attr['CASE']);
|
||||
$this->assertSame('NATURAL', $attr['CASE']->class);
|
||||
$this->assertSame('BOTH', $attr['DEFAULT_FETCH_MODE']->class);
|
229
vendor/symfony/var-dumper/Tests/Caster/ReflectionCasterTest.php
vendored
Normal file
229
vendor/symfony/var-dumper/Tests/Caster/ReflectionCasterTest.php
vendored
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
use Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo;
|
||||
use Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ReflectionCasterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
public function testReflectionCaster()
|
||||
{
|
||||
$var = new \ReflectionClass('ReflectionClass');
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
ReflectionClass {
|
||||
+name: "ReflectionClass"
|
||||
%Aimplements: array:%d [
|
||||
0 => "Reflector"
|
||||
%A]
|
||||
constants: array:3 [
|
||||
"IS_IMPLICIT_ABSTRACT" => 16
|
||||
"IS_EXPLICIT_ABSTRACT" => 32
|
||||
"IS_FINAL" => %d
|
||||
]
|
||||
properties: array:%d [
|
||||
"name" => ReflectionProperty {
|
||||
%A +name: "name"
|
||||
+class: "ReflectionClass"
|
||||
%A modifiers: "public"
|
||||
}
|
||||
%A]
|
||||
methods: array:%d [
|
||||
%A
|
||||
"export" => ReflectionMethod {
|
||||
+name: "export"
|
||||
+class: "ReflectionClass"
|
||||
%A parameters: {
|
||||
$%s: ReflectionParameter {
|
||||
%A position: 0
|
||||
%A
|
||||
}
|
||||
EOTXT
|
||||
, $var
|
||||
);
|
||||
}
|
||||
|
||||
public function testClosureCaster()
|
||||
{
|
||||
$a = $b = 123;
|
||||
$var = function ($x) use ($a, &$b) {};
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
Closure {
|
||||
%Aparameters: {
|
||||
\$x: {}
|
||||
}
|
||||
use: {
|
||||
\$a: 123
|
||||
\$b: & 123
|
||||
}
|
||||
file: "%sReflectionCasterTest.php"
|
||||
line: "66 to 66"
|
||||
}
|
||||
EOTXT
|
||||
, $var
|
||||
);
|
||||
}
|
||||
|
||||
public function testReflectionParameter()
|
||||
{
|
||||
$var = new \ReflectionParameter(__NAMESPACE__.'\reflectionParameterFixture', 0);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
ReflectionParameter {
|
||||
+name: "arg1"
|
||||
position: 0
|
||||
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
|
||||
default: null
|
||||
}
|
||||
EOTXT
|
||||
, $var
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
public function testReflectionParameterScalar()
|
||||
{
|
||||
$f = eval('return function (int $a) {};');
|
||||
$var = new \ReflectionParameter($f, 0);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
ReflectionParameter {
|
||||
+name: "a"
|
||||
position: 0
|
||||
typeHint: "int"
|
||||
}
|
||||
EOTXT
|
||||
, $var
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
public function testReturnType()
|
||||
{
|
||||
$f = eval('return function ():int {};');
|
||||
$line = __LINE__ - 1;
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
Closure {
|
||||
returnType: "int"
|
||||
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
|
||||
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
|
||||
file: "%sReflectionCasterTest.php($line) : eval()'d code"
|
||||
line: "1 to 1"
|
||||
}
|
||||
EOTXT
|
||||
, $f
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
public function testGenerator()
|
||||
{
|
||||
$g = new GeneratorDemo();
|
||||
$g = $g->baz();
|
||||
$r = new \ReflectionGenerator($g);
|
||||
|
||||
$xDump = <<<'EODUMP'
|
||||
Generator {
|
||||
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
|
||||
executing: {
|
||||
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz(): {
|
||||
%sGeneratorDemo.php:14: """
|
||||
{\n
|
||||
yield from bar();\n
|
||||
}\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
EODUMP;
|
||||
|
||||
$this->assertDumpMatchesFormat($xDump, $g);
|
||||
|
||||
foreach ($g as $v) {
|
||||
break;
|
||||
}
|
||||
|
||||
$xDump = <<<'EODUMP'
|
||||
array:2 [
|
||||
0 => ReflectionGenerator {
|
||||
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
|
||||
trace: {
|
||||
3. Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() ==> yield(): {
|
||||
src: {
|
||||
%sGeneratorDemo.php:9: """
|
||||
{\n
|
||||
yield 1;\n
|
||||
}\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
2. Symfony\Component\VarDumper\Tests\Fixtures\bar() ==> Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo(): {
|
||||
src: {
|
||||
%sGeneratorDemo.php:20: """
|
||||
{\n
|
||||
yield from GeneratorDemo::foo();\n
|
||||
}\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
1. Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() ==> Symfony\Component\VarDumper\Tests\Fixtures\bar(): {
|
||||
src: {
|
||||
%sGeneratorDemo.php:14: """
|
||||
{\n
|
||||
yield from bar();\n
|
||||
}\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1 => Generator {
|
||||
executing: {
|
||||
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo(): {
|
||||
%sGeneratorDemo.php:10: """
|
||||
yield 1;\n
|
||||
}\n
|
||||
\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
EODUMP;
|
||||
|
||||
$this->assertDumpMatchesFormat($xDump, array($r, $r->getExecutingGenerator()));
|
||||
}
|
||||
}
|
||||
|
||||
function reflectionParameterFixture(NotLoadableClass $arg1 = null, $arg2)
|
||||
{
|
||||
}
|
120
vendor/symfony/var-dumper/Tests/Caster/SplCasterTest.php
vendored
Normal file
120
vendor/symfony/var-dumper/Tests/Caster/SplCasterTest.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
|
||||
/**
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
class SplCasterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
public function getCastFileInfoTests()
|
||||
{
|
||||
return array(
|
||||
array(__FILE__, <<<'EOTXT'
|
||||
SplFileInfo {
|
||||
%Apath: "%sCaster"
|
||||
filename: "SplCasterTest.php"
|
||||
basename: "SplCasterTest.php"
|
||||
pathname: "%sSplCasterTest.php"
|
||||
extension: "php"
|
||||
realPath: "%sSplCasterTest.php"
|
||||
aTime: %s-%s-%d %d:%d:%d
|
||||
mTime: %s-%s-%d %d:%d:%d
|
||||
cTime: %s-%s-%d %d:%d:%d
|
||||
inode: %d
|
||||
size: %d
|
||||
perms: 0%d
|
||||
owner: %d
|
||||
group: %d
|
||||
type: "file"
|
||||
writable: true
|
||||
readable: true
|
||||
executable: false
|
||||
file: true
|
||||
dir: false
|
||||
link: false
|
||||
%A}
|
||||
EOTXT
|
||||
),
|
||||
array('https://google.com/about', <<<'EOTXT'
|
||||
SplFileInfo {
|
||||
%Apath: "https://google.com"
|
||||
filename: "about"
|
||||
basename: "about"
|
||||
pathname: "https://google.com/about"
|
||||
extension: ""
|
||||
realPath: false
|
||||
%A}
|
||||
EOTXT
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/** @dataProvider getCastFileInfoTests */
|
||||
public function testCastFileInfo($file, $dump)
|
||||
{
|
||||
$this->assertDumpMatchesFormat($dump, new \SplFileInfo($file));
|
||||
}
|
||||
|
||||
public function testCastFileObject()
|
||||
{
|
||||
$var = new \SplFileObject(__FILE__);
|
||||
$var->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
|
||||
$dump = <<<'EOTXT'
|
||||
SplFileObject {
|
||||
%Apath: "%sCaster"
|
||||
filename: "SplCasterTest.php"
|
||||
basename: "SplCasterTest.php"
|
||||
pathname: "%sSplCasterTest.php"
|
||||
extension: "php"
|
||||
realPath: "%sSplCasterTest.php"
|
||||
aTime: %s-%s-%d %d:%d:%d
|
||||
mTime: %s-%s-%d %d:%d:%d
|
||||
cTime: %s-%s-%d %d:%d:%d
|
||||
inode: %d
|
||||
size: %d
|
||||
perms: 0%d
|
||||
owner: %d
|
||||
group: %d
|
||||
type: "file"
|
||||
writable: true
|
||||
readable: true
|
||||
executable: false
|
||||
file: true
|
||||
dir: false
|
||||
link: false
|
||||
%AcsvControl: array:2 [
|
||||
0 => ","
|
||||
1 => """
|
||||
]
|
||||
flags: DROP_NEW_LINE|SKIP_EMPTY
|
||||
maxLineLen: 0
|
||||
fstat: array:26 [
|
||||
"dev" => %d
|
||||
"ino" => %d
|
||||
"nlink" => %d
|
||||
"rdev" => 0
|
||||
"blksize" => %i
|
||||
"blocks" => %i
|
||||
…20
|
||||
]
|
||||
eof: false
|
||||
key: 0
|
||||
}
|
||||
EOTXT;
|
||||
$this->assertDumpMatchesFormat($dump, $var);
|
||||
}
|
||||
}
|
@@ -13,12 +13,15 @@ namespace Symfony\Component\VarDumper\Tests;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CliDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
require __DIR__.'/Fixtures/dumb-var.php';
|
||||
@@ -59,31 +62,29 @@ array:24 [
|
||||
7 => b"é\\x00"
|
||||
"[]" => []
|
||||
"res" => stream resource {@{$res}
|
||||
wrapper_type: "plainfile"
|
||||
%A wrapper_type: "plainfile"
|
||||
stream_type: "STDIO"
|
||||
mode: "r"
|
||||
unread_bytes: 0
|
||||
seekable: true
|
||||
timed_out: false
|
||||
blocked: true
|
||||
eof: false
|
||||
options: []
|
||||
%A options: []
|
||||
}
|
||||
"obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d
|
||||
+foo: "foo"
|
||||
+"bar": "bar"
|
||||
}
|
||||
"closure" => Closure {{$r}
|
||||
reflection: """
|
||||
Closure [ <user%S> %s Symfony\Component\VarDumper\Tests\Fixture\{closure} ] {\\n
|
||||
@@ {$var['file']} {$var['line']} - {$var['line']}\\n
|
||||
\\n
|
||||
- Parameters [2] {\\n
|
||||
Parameter #0 [ <required> \$a ]\\n
|
||||
Parameter #1 [ <optional> PDO or NULL &\$b = NULL ]\\n
|
||||
}\\n
|
||||
}\\n
|
||||
"""
|
||||
class: "Symfony\Component\VarDumper\Tests\CliDumperTest"
|
||||
this: Symfony\Component\VarDumper\Tests\CliDumperTest {{$r} …}
|
||||
parameters: {
|
||||
\$a: {}
|
||||
&\$b: {
|
||||
typeHint: "PDO"
|
||||
default: null
|
||||
}
|
||||
}
|
||||
file: "{$var['file']}"
|
||||
line: "{$var['line']} to {$var['line']}"
|
||||
}
|
||||
"line" => {$var['line']}
|
||||
"nobj" => array:1 [
|
||||
@@ -106,6 +107,27 @@ EOTXT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension xml
|
||||
*/
|
||||
public function testXmlResource()
|
||||
{
|
||||
$var = xml_parser_create();
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
xml resource {
|
||||
current_byte_index: %i
|
||||
current_column_number: %i
|
||||
current_line_number: 1
|
||||
error_code: XML_ERROR_NONE
|
||||
}
|
||||
EOTXT
|
||||
,
|
||||
$var
|
||||
);
|
||||
}
|
||||
|
||||
public function testClosedResource()
|
||||
{
|
||||
if (defined('HHVM_VERSION') && HHVM_VERSION_ID < 30600) {
|
||||
@@ -139,6 +161,9 @@ EOTXT
|
||||
{
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
|
||||
require_once __DIR__.'/Fixtures/Twig.php';
|
||||
$twig = new \__TwigTemplate_VarDumperFixture_u75a09(new \Twig_Environment(new \Twig_Loader_Filesystem()));
|
||||
|
||||
$dumper = new CliDumper();
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
@@ -150,12 +175,15 @@ EOTXT
|
||||
},
|
||||
));
|
||||
$cloner->addCasters(array(
|
||||
':stream' => function () {
|
||||
throw new \Exception('Foobar');
|
||||
},
|
||||
':stream' => eval('return function () use ($twig) {
|
||||
try {
|
||||
$twig->render(array());
|
||||
} catch (\Twig_Error_Runtime $e) {
|
||||
throw $e->getPrevious();
|
||||
}
|
||||
};'),
|
||||
));
|
||||
$line = __LINE__ - 3;
|
||||
$file = __FILE__;
|
||||
$line = __LINE__ - 2;
|
||||
$ref = (int) $out;
|
||||
|
||||
$data = $cloner->cloneVar($out);
|
||||
@@ -163,28 +191,79 @@ EOTXT
|
||||
rewind($out);
|
||||
$out = stream_get_contents($out);
|
||||
|
||||
if (method_exists($twig, 'getSource')) {
|
||||
$twig = <<<EOTXT
|
||||
foo.twig:2: """
|
||||
foo bar\\n
|
||||
twig source\\n
|
||||
\\n
|
||||
"""
|
||||
|
||||
EOTXT;
|
||||
} else {
|
||||
$twig = '';
|
||||
}
|
||||
|
||||
$r = defined('HHVM_VERSION') ? '' : '#%d';
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
stream resource {@{$ref}
|
||||
wrapper_type: "PHP"
|
||||
%Awrapper_type: "PHP"
|
||||
stream_type: "MEMORY"
|
||||
mode: "%s+b"
|
||||
unread_bytes: 0
|
||||
seekable: true
|
||||
uri: "php://memory"
|
||||
timed_out: false
|
||||
blocked: true
|
||||
eof: false
|
||||
options: []
|
||||
%Aoptions: []
|
||||
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {{$r}
|
||||
#message: "Unexpected Exception thrown from a caster: Foobar"
|
||||
trace: array:1 [
|
||||
0 => array:2 [
|
||||
"call" => "%slosure%s()"
|
||||
"file" => "{$file}:{$line}"
|
||||
]
|
||||
]
|
||||
-trace: {
|
||||
%d. __TwigTemplate_VarDumperFixture_u75a09->doDisplay() ==> new Exception(): {
|
||||
src: {
|
||||
%sTwig.php:19: """
|
||||
// line 2\\n
|
||||
throw new \Exception('Foobar');\\n
|
||||
}\\n
|
||||
"""
|
||||
{$twig} }
|
||||
}
|
||||
%d. Twig_Template->displayWithErrorHandling() ==> __TwigTemplate_VarDumperFixture_u75a09->doDisplay(): {
|
||||
src: {
|
||||
%sTemplate.php:%d: """
|
||||
try {\\n
|
||||
\$this->doDisplay(\$context, \$blocks);\\n
|
||||
} catch (Twig_Error \$e) {\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
%d. Twig_Template->display() ==> Twig_Template->displayWithErrorHandling(): {
|
||||
src: {
|
||||
%sTemplate.php:%d: """
|
||||
{\\n
|
||||
\$this->displayWithErrorHandling(\$this->env->mergeGlobals(\$context), array_merge(\$this->blocks, \$blocks));\\n
|
||||
}\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
%d. Twig_Template->render() ==> Twig_Template->display(): {
|
||||
src: {
|
||||
%sTemplate.php:%d: """
|
||||
try {\\n
|
||||
\$this->display(\$context);\\n
|
||||
} catch (Exception \$e) {\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
%d. %slosure%s() ==> Twig_Template->render(): {
|
||||
src: {
|
||||
%sCliDumperTest.php:{$line}: """
|
||||
}\\n
|
||||
};'),\\n
|
||||
));\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,26 +305,13 @@ EOTXT
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @requires PHP 5.6
|
||||
*/
|
||||
public function testSpecialVars56()
|
||||
{
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
$this->markTestSkipped('PHP 5.6 is required');
|
||||
}
|
||||
|
||||
$var = $this->getSpecialVars();
|
||||
|
||||
$dumper = new CliDumper();
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$data = $cloner->cloneVar($var);
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
$dumper->dump($data, $out);
|
||||
rewind($out);
|
||||
$out = stream_get_contents($out);
|
||||
|
||||
$this->assertSame(
|
||||
$this->assertDumpEquals(
|
||||
<<<EOTXT
|
||||
array:3 [
|
||||
0 => array:1 [
|
||||
@@ -260,10 +326,9 @@ array:3 [
|
||||
]
|
||||
2 => &2 array:1 [&2]
|
||||
]
|
||||
|
||||
EOTXT
|
||||
,
|
||||
$out
|
||||
$var
|
||||
);
|
||||
}
|
||||
|
||||
@@ -326,7 +391,7 @@ EOTXT
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$data = $cloner->cloneVar($var)->getLimitedClone(3, -1);
|
||||
$data = $cloner->cloneVar($var)->withMaxDepth(3);
|
||||
$out = '';
|
||||
$dumper->dump($data, function ($line, $depth) use (&$out) {
|
||||
if ($depth >= 0) {
|
||||
@@ -339,9 +404,7 @@ EOTXT
|
||||
array:1 [
|
||||
0 => array:1 [
|
||||
0 => array:1 [
|
||||
0 => array:1 [
|
||||
…1
|
||||
]
|
||||
0 => array:1 [ …1]
|
||||
]
|
||||
]
|
||||
]
|
21
vendor/symfony/var-dumper/Tests/Fixtures/GeneratorDemo.php
vendored
Normal file
21
vendor/symfony/var-dumper/Tests/Fixtures/GeneratorDemo.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Fixtures;
|
||||
|
||||
class GeneratorDemo
|
||||
{
|
||||
public static function foo()
|
||||
{
|
||||
yield 1;
|
||||
}
|
||||
|
||||
public function baz()
|
||||
{
|
||||
yield from bar();
|
||||
}
|
||||
}
|
||||
|
||||
function bar()
|
||||
{
|
||||
yield from GeneratorDemo::foo();
|
||||
}
|
7
vendor/symfony/var-dumper/Tests/Fixtures/NotLoadableClass.php
vendored
Normal file
7
vendor/symfony/var-dumper/Tests/Fixtures/NotLoadableClass.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Fixtures;
|
||||
|
||||
class NotLoadableClass extends NotLoadableClass
|
||||
{
|
||||
}
|
34
vendor/symfony/var-dumper/Tests/Fixtures/Twig.php
vendored
Normal file
34
vendor/symfony/var-dumper/Tests/Fixtures/Twig.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_VarDumperFixture_u75a09 extends Twig_Template
|
||||
{
|
||||
public function __construct(Twig_Environment $env)
|
||||
{
|
||||
parent::__construct($env);
|
||||
|
||||
$this->parent = false;
|
||||
|
||||
$this->blocks = array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function doDisplay(array $context, array $blocks = array())
|
||||
{
|
||||
// line 2
|
||||
throw new \Exception('Foobar');
|
||||
}
|
||||
|
||||
public function getTemplateName()
|
||||
{
|
||||
return 'foo.twig';
|
||||
}
|
||||
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array (19 => 2);
|
||||
}
|
||||
}
|
||||
/* foo bar*/
|
||||
/* twig source*/
|
||||
/* */
|
@@ -59,35 +59,33 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
<span class=sf-dump-key>4</span> => <span class=sf-dump-num>INF</span>
|
||||
<span class=sf-dump-key>5</span> => <span class=sf-dump-num>-INF</span>
|
||||
<span class=sf-dump-key>6</span> => <span class=sf-dump-num>{$intMax}</span>
|
||||
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">déjà</span>\\n"
|
||||
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">é</span>\\x00"
|
||||
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">d&%s;j&%s;</span>\\n"
|
||||
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&%s;</span>\\x00"
|
||||
"<span class=sf-dump-key>[]</span>" => []
|
||||
"<span class=sf-dump-key>res</span>" => <span class=sf-dump-note>stream resource</span> <a class=sf-dump-ref>@{$res}</a><samp>
|
||||
<span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"
|
||||
%A <span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"
|
||||
<span class=sf-dump-meta>stream_type</span>: "<span class=sf-dump-str title="5 characters">STDIO</span>"
|
||||
<span class=sf-dump-meta>mode</span>: "<span class=sf-dump-str>r</span>"
|
||||
<span class=sf-dump-meta>unread_bytes</span>: <span class=sf-dump-num>0</span>
|
||||
<span class=sf-dump-meta>seekable</span>: <span class=sf-dump-const>true</span>
|
||||
<span class=sf-dump-meta>timed_out</span>: <span class=sf-dump-const>false</span>
|
||||
<span class=sf-dump-meta>blocked</span>: <span class=sf-dump-const>true</span>
|
||||
<span class=sf-dump-meta>eof</span>: <span class=sf-dump-const>false</span>
|
||||
<span class=sf-dump-meta>options</span>: []
|
||||
%A <span class=sf-dump-meta>options</span>: []
|
||||
</samp>}
|
||||
"<span class=sf-dump-key>obj</span>" => <abbr title="Symfony\Component\VarDumper\Tests\Fixture\DumbFoo" class=sf-dump-note>DumbFoo</abbr> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="2 occurrences">#%d</a><samp id={$dumpId}-ref2%d>
|
||||
+<span class=sf-dump-public title="Public property">foo</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
|
||||
+"<span class=sf-dump-public title="Runtime added dynamic property">bar</span>": "<span class=sf-dump-str title="3 characters">bar</span>"
|
||||
</samp>}
|
||||
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure</span> {{$r}<samp>
|
||||
<span class=sf-dump-meta>reflection</span>: """
|
||||
<span class=sf-dump-str title="%d characters">Closure [ <user%S> %s Symfony\Component\VarDumper\Tests\Fixture\{closure} ] {</span>\\n
|
||||
<span class=sf-dump-str title="%d characters"> @@ {$var['file']} {$var['line']} - {$var['line']}</span>\\n
|
||||
\\n
|
||||
<span class=sf-dump-str title="%d characters"> - Parameters [2] {</span>\\n
|
||||
<span class=sf-dump-str title="%d characters"> Parameter #0 [ <required> \$a ]</span>\\n
|
||||
<span class=sf-dump-str title="%d characters"> Parameter #1 [ <optional> PDO or NULL &\$b = NULL ]</span>\\n
|
||||
<span class=sf-dump-str title="%d characters"> }</span>\\n
|
||||
<span class=sf-dump-str title="%d characters">}</span>\\n
|
||||
"""
|
||||
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="48 characters">Symfony\Component\VarDumper\Tests\HtmlDumperTest</span>"
|
||||
<span class=sf-dump-meta>this</span>: <abbr title="Symfony\Component\VarDumper\Tests\HtmlDumperTest" class=sf-dump-note>HtmlDumperTest</abbr> {{$r} &%s;}
|
||||
<span class=sf-dump-meta>parameters</span>: {<samp>
|
||||
<span class=sf-dump-meta>\$a</span>: {}
|
||||
<span class=sf-dump-meta>&\$b</span>: {<samp>
|
||||
<span class=sf-dump-meta>typeHint</span>: "<span class=sf-dump-str title="3 characters">PDO</span>"
|
||||
<span class=sf-dump-meta>default</span>: <span class=sf-dump-const>null</span>
|
||||
</samp>}
|
||||
</samp>}
|
||||
<span class=sf-dump-meta>file</span>: "<span class=sf-dump-str title="%d characters">{$var['file']}</span>"
|
||||
<span class=sf-dump-meta>line</span>: "<span class=sf-dump-str title="%d characters">{$var['line']} to {$var['line']}</span>"
|
||||
</samp>}
|
||||
"<span class=sf-dump-key>line</span>" => <span class=sf-dump-num>{$var['line']}</span>
|
||||
"<span class=sf-dump-key>nobj</span>" => <span class=sf-dump-note>array:1</span> [<samp>
|
||||
@@ -101,7 +99,7 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
"<span class=sf-dump-key>snobj</span>" => <a class=sf-dump-ref href=#{$dumpId}-ref03 title="2 occurrences">&3</a> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="3 occurrences">#%d</a>}
|
||||
"<span class=sf-dump-key>snobj2</span>" => {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="3 occurrences">#%d</a>}
|
||||
"<span class=sf-dump-key>file</span>" => "<span class=sf-dump-str title="%d characters">{$var['file']}</span>"
|
||||
b"<span class=sf-dump-key>bin-key-é</span>" => ""
|
||||
b"<span class=sf-dump-key>bin-key-&%s;</span>" => ""
|
||||
</samp>]
|
||||
</bar>
|
||||
|
||||
@@ -114,9 +112,6 @@ EOTXT
|
||||
|
||||
public function testCharset()
|
||||
{
|
||||
if (!extension_loaded('mbstring')) {
|
||||
$this->markTestSkipped('This test requires mbstring.');
|
||||
}
|
||||
$var = mb_convert_encoding('Словарь', 'CP1251', 'UTF-8');
|
||||
|
||||
$dumper = new HtmlDumper('php://output', 'CP1251');
|
40
vendor/symfony/var-dumper/Tests/Test/VarDumperTestTraitTest.php
vendored
Normal file
40
vendor/symfony/var-dumper/Tests/Test/VarDumperTestTraitTest.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Test;
|
||||
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
|
||||
class VarDumperTestTraitTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
public function testItComparesLargeData()
|
||||
{
|
||||
$howMany = 700;
|
||||
$data = array_fill_keys(range(0, $howMany), array('a', 'b', 'c', 'd'));
|
||||
|
||||
$expected = sprintf("array:%d [\n", $howMany + 1);
|
||||
for ($i = 0; $i <= $howMany; ++$i) {
|
||||
$expected .= <<<EODUMP
|
||||
$i => array:4 [
|
||||
0 => "a"
|
||||
1 => "b"
|
||||
2 => "c"
|
||||
3 => "d"
|
||||
]\n
|
||||
EODUMP;
|
||||
}
|
||||
$expected .= "]\n";
|
||||
|
||||
$this->assertDumpEquals($expected, $data);
|
||||
}
|
||||
}
|
@@ -131,6 +131,56 @@ Symfony\Component\VarDumper\Cloner\Data Object
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertStringMatchesFormat($expected, print_r($clone, true));
|
||||
}
|
||||
|
||||
public function testCaster()
|
||||
{
|
||||
$cloner = new VarCloner(array(
|
||||
'*' => function ($obj, $array) {
|
||||
return array('foo' => 123);
|
||||
},
|
||||
__CLASS__ => function ($obj, $array) {
|
||||
++$array['foo'];
|
||||
|
||||
return $array;
|
||||
},
|
||||
));
|
||||
$clone = $cloner->cloneVar($this);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => object
|
||||
[class] => %s
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[foo] => 124
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertStringMatchesFormat($expected, print_r($clone, true));
|
||||
}
|
@@ -38,12 +38,8 @@ class VarDumper
|
||||
return call_user_func(self::$handler, $var);
|
||||
}
|
||||
|
||||
public static function setHandler($callable)
|
||||
public static function setHandler(callable $callable = null)
|
||||
{
|
||||
if (null !== $callable && !is_callable($callable, true)) {
|
||||
throw new \InvalidArgumentException('Invalid PHP callback.');
|
||||
}
|
||||
|
||||
$prevHandler = self::$handler;
|
||||
self::$handler = $callable;
|
||||
|
@@ -16,23 +16,26 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.5.9",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
"twig/twig": "~1.20|~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-symfony_debug": ""
|
||||
},
|
||||
"autoload": {
|
||||
"files": [ "Resources/functions/dump.php" ],
|
||||
"psr-0": { "Symfony\\Component\\VarDumper\\": "" }
|
||||
"psr-4": { "Symfony\\Component\\VarDumper\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"target-dir": "Symfony/Component/VarDumper",
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,6 +9,7 @@
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony VarDumper Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
@@ -19,8 +20,8 @@
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./Resources</directory>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
Reference in New Issue
Block a user