update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -131,7 +131,7 @@ class AmqpCaster
$prefix.'contentType' => $c->getContentType(),
$prefix.'contentEncoding' => $c->getContentEncoding(),
$prefix.'type' => $c->getType(),
$prefix.'timestamp' => $c->getTimestamp(),
$prefix.'timestamp' => $c->getTimeStamp(),
$prefix.'priority' => $c->getPriority(),
$prefix.'expiration' => $c->getExpiration(),
$prefix.'userId' => $c->getUserId(),

View File

@@ -36,15 +36,17 @@ class Caster
/**
* 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.
* @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.
* @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();
} elseif ($obj instanceof \Closure) {
$a = array();
} else {
$a = (array) $obj;
}
@@ -52,7 +54,7 @@ class Caster
if ($a) {
$p = array_keys($a);
foreach ($p as $i => $k) {
if (!isset($k[0]) || ("\0" !== $k[0] && !$reflector->hasProperty($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");
@@ -70,9 +72,9 @@ class Caster
* 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.
* @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
*/

View File

@@ -198,7 +198,7 @@ class ExceptionCaster
'file' => $a[Caster::PREFIX_PROTECTED.'file'],
'line' => $a[Caster::PREFIX_PROTECTED.'line'],
));
$a[$xPrefix.'trace'] = new TraceStub($trace);
$a[$xPrefix.'trace'] = new TraceStub($trace, self::$traceArgs);
}
if (empty($a[$xPrefix.'previous'])) {
unset($a[$xPrefix.'previous']);
@@ -217,19 +217,24 @@ class ExceptionCaster
}
$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;
do {
$pad = null;
for ($i = $srcContext << 1; $i >= 0; --$i) {
if (isset($src[$i][$ltrim]) && "\r" !== ($c = $src[$i][$ltrim]) && "\n" !== $c) {
if (null === $pad) {
$pad = $c;
}
if ((' ' !== $c && "\t" !== $c) || $pad !== $c) {
break;
}
}
}
++$ltrim;
}
if ($ltrim) {
} while (0 > $i && null !== $pad);
if (--$ltrim) {
foreach ($src as $i => $line) {
$src[$i] = substr($line, $ltrim);
$src[$i] = isset($line[$ltrim]) && "\r" !== $line[$ltrim] ? substr($line, $ltrim) : ltrim($line, " \t");
}
}

View File

@@ -58,7 +58,7 @@ class ReflectionCaster
}
$prefix = Caster::PREFIX_DYNAMIC;
unset($a['name'], $a[$prefix.'0'], $a[$prefix.'this'], $a[$prefix.'parameter'], $a[Caster::PREFIX_VIRTUAL.'extra']);
unset($a['name'], $a[$prefix.'this'], $a[$prefix.'parameter'], $a[Caster::PREFIX_VIRTUAL.'extra']);
return $a;
}

View File

@@ -125,7 +125,7 @@ abstract class AbstractCloner implements ClonerInterface
private $filter = 0;
/**
* @param callable[]|null $casters A map of casters.
* @param callable[]|null $casters A map of casters
*
* @see addCasters
*/
@@ -146,7 +146,7 @@ abstract class AbstractCloner implements ClonerInterface
* Resource types are to be prefixed with a `:`,
* see e.g. static::$defaultCasters.
*
* @param callable[] $casters A map of casters.
* @param callable[] $casters A map of casters
*/
public function addCasters(array $casters)
{
@@ -178,10 +178,10 @@ abstract class AbstractCloner implements ClonerInterface
/**
* Clones a PHP variable.
*
* @param mixed $var Any PHP variable.
* @param int $filter A bit field of Caster::EXCLUDE_* constants.
* @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.
* @return Data The cloned variable represented by a Data object
*/
public function cloneVar($var, $filter = 0)
{
@@ -216,19 +216,19 @@ abstract class AbstractCloner implements ClonerInterface
/**
* Effectively clones the PHP variable.
*
* @param mixed $var Any PHP variable.
* @param mixed $var Any PHP variable
*
* @return array The cloned variable represented in an array.
* @return array The cloned variable represented in an array
*/
abstract protected function doClone($var);
/**
* Casts an object to an array representation.
*
* @param Stub $stub The Stub for the casted object.
* @param bool $isNested True if the object is nested in the dumped structure.
* @param Stub $stub The Stub for the casted object
* @param bool $isNested True if the object is nested in the dumped structure
*
* @return array The object casted as array.
* @return array The object casted as array
*/
protected function castObject(Stub $stub, $isNested)
{
@@ -265,10 +265,10 @@ abstract class AbstractCloner implements ClonerInterface
/**
* Casts a resource to an array representation.
*
* @param Stub $stub The Stub for the casted resource.
* @param bool $isNested True if the object is nested in the dumped structure.
* @param Stub $stub The Stub for the casted resource
* @param bool $isNested True if the object is nested in the dumped structure
*
* @return array The resource casted as array.
* @return array The resource casted as array
*/
protected function castResource(Stub $stub, $isNested)
{
@@ -288,13 +288,13 @@ abstract class AbstractCloner implements ClonerInterface
/**
* Calls a custom caster.
*
* @param callable $callback The caster.
* @param object|resource $obj The object/resource being casted.
* @param array $a The result of the previous cast for chained casters.
* @param Stub $stub The Stub for the casted object/resource.
* @param bool $isNested True if $obj is nested in the dumped structure.
* @param callable $callback The caster
* @param object|resource $obj The object/resource being casted
* @param array $a The result of the previous cast for chained casters
* @param Stub $stub The Stub for the casted object/resource
* @param bool $isNested True if $obj is nested in the dumped structure
*
* @return array The casted object/resource.
* @return array The casted object/resource
*/
private function callCaster($callback, $obj, $a, $stub, $isNested)
{

View File

@@ -19,9 +19,9 @@ interface ClonerInterface
/**
* Clones a PHP variable.
*
* @param mixed $var Any PHP variable.
* @param mixed $var Any PHP variable
*
* @return Data The cloned variable represented by a Data object.
* @return Data The cloned variable represented by a Data object
*/
public function cloneVar($var);
}

View File

@@ -22,7 +22,7 @@ class Data
private $useRefHandles = -1;
/**
* @param array $data A array as returned by ClonerInterface::cloneVar().
* @param array $data A array as returned by ClonerInterface::cloneVar()
*/
public function __construct(array $data)
{
@@ -30,7 +30,7 @@ class Data
}
/**
* @return array The raw data structure.
* @return array The raw data structure
*/
public function getRawData()
{
@@ -40,9 +40,9 @@ class Data
/**
* Returns a depth limited clone of $this.
*
* @param int $maxDepth The max dumped depth level.
* @param int $maxDepth The max dumped depth level
*
* @return self A clone of $this.
* @return self A clone of $this
*/
public function withMaxDepth($maxDepth)
{
@@ -55,9 +55,9 @@ class Data
/**
* Limits the number of elements per depth level.
*
* @param int $maxItemsPerDepth The max number of items dumped per depth level.
* @param int $maxItemsPerDepth The max number of items dumped per depth level
*
* @return self A clone of $this.
* @return self A clone of $this
*/
public function withMaxItemsPerDepth($maxItemsPerDepth)
{
@@ -70,9 +70,9 @@ class Data
/**
* Enables/disables objects' identifiers tracking.
*
* @param bool $useRefHandles False to hide global ref. handles.
* @param bool $useRefHandles False to hide global ref. handles
*
* @return self A clone of $this.
* @return self A clone of $this
*/
public function withRefHandles($useRefHandles)
{
@@ -94,10 +94,10 @@ class Data
/**
* Depth-first dumping of items.
*
* @param DumperInterface $dumper The dumper being used for dumping.
* @param Cursor $cursor A cursor used for tracking dumper state position.
* @param array &$refs A map of all references discovered while dumping.
* @param mixed $item A Stub object or the original value being dumped.
* @param DumperInterface $dumper The dumper being used for dumping
* @param Cursor $cursor A cursor used for tracking dumper state position
* @param array &$refs A map of all references discovered while dumping
* @param mixed $item A Stub object or the original value being dumped
*/
private function dumpItem($dumper, $cursor, &$refs, $item)
{
@@ -186,13 +186,13 @@ class Data
* Dumps children of hash structures.
*
* @param DumperInterface $dumper
* @param Cursor $parentCursor The cursor of the parent hash.
* @param array &$refs A map of all references discovered while dumping.
* @param array $children The children to dump.
* @param int $hashCut The number of items removed from the original hash.
* @param string $hashType A Cursor::HASH_* const.
* @param Cursor $parentCursor The cursor of the parent hash
* @param array &$refs A map of all references discovered while dumping
* @param array $children The children to dump
* @param int $hashCut The number of items removed from the original hash
* @param string $hashType A Cursor::HASH_* const
*
* @return int The final number of removed items.
* @return int The final number of removed items
*/
private function dumpChildren($dumper, $parentCursor, &$refs, $children, $hashCut, $hashType)
{

View File

@@ -21,40 +21,40 @@ interface DumperInterface
/**
* Dumps a scalar value.
*
* @param Cursor $cursor The Cursor position in the dump.
* @param string $type The PHP type of the value being dumped.
* @param scalar $value The scalar value being dumped.
* @param Cursor $cursor The Cursor position in the dump
* @param string $type The PHP type of the value being dumped
* @param scalar $value The scalar value being dumped
*/
public function dumpScalar(Cursor $cursor, $type, $value);
/**
* Dumps a string.
*
* @param Cursor $cursor The Cursor position in the dump.
* @param string $str The string being dumped.
* @param bool $bin Whether $str is UTF-8 or binary encoded.
* @param int $cut The number of characters $str has been cut by.
* @param Cursor $cursor The Cursor position in the dump
* @param string $str The string being dumped
* @param bool $bin Whether $str is UTF-8 or binary encoded
* @param int $cut The number of characters $str has been cut by
*/
public function dumpString(Cursor $cursor, $str, $bin, $cut);
/**
* Dumps while entering an hash.
*
* @param Cursor $cursor The Cursor position in the dump.
* @param int $type A Cursor::HASH_* const for the type of hash.
* @param string $class The object class, resource type or array count.
* @param bool $hasChild When the dump of the hash has child item.
* @param Cursor $cursor The Cursor position in the dump
* @param int $type A Cursor::HASH_* const for the type of hash
* @param string $class The object class, resource type or array count
* @param bool $hasChild When the dump of the hash has child item
*/
public function enterHash(Cursor $cursor, $type, $class, $hasChild);
/**
* Dumps while leaving an hash.
*
* @param Cursor $cursor The Cursor position in the dump.
* @param int $type A Cursor::HASH_* const for the type of hash.
* @param string $class The object class, resource type or array count.
* @param bool $hasChild When the dump of the hash has child item.
* @param int $cut The number of items the hash has been cut by.
* @param Cursor $cursor The Cursor position in the dump
* @param int $type A Cursor::HASH_* const for the type of hash
* @param string $class The object class, resource type or array count
* @param bool $hasChild When the dump of the hash has child item
* @param int $cut The number of items the hash has been cut by
*/
public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut);
}

View File

@@ -28,7 +28,7 @@ class VarCloner extends AbstractCloner
$i = 0; // Current iteration position in $queue
$len = 1; // Length of $queue
$pos = 0; // Number of cloned items past the first level
$refs = 0; // Hard references counter
$refsCounter = 0; // Hard references counter
$queue = array(array($var)); // This breadth-first queue is the return value
$arrayRefs = array(); // Map of queue indexes to stub array objects
$hardRefs = array(); // Map of original zval hashes to stub objects
@@ -60,27 +60,32 @@ class VarCloner extends AbstractCloner
for ($i = 0; $i < $len; ++$i) {
$indexed = true; // Whether the currently iterated array is numerically indexed or not
$j = -1; // Position in the currently iterated array
$step = $queue[$i]; // Copy of the currently iterated array used for hard references detection
foreach ($step as $k => $v) {
$fromObjCast = array_keys($queue[$i]);
$fromObjCast = array_keys(array_flip($fromObjCast)) !== $fromObjCast;
$refs = $vals = $fromObjCast ? array_values($queue[$i]) : $queue[$i];
foreach ($queue[$i] as $k => $v) {
// $k is the original key
// $v is the original value or a stub object in case of hard references
if ($indexed && $k !== ++$j) {
if ($k !== ++$j) {
$indexed = false;
}
if ($fromObjCast) {
$k = $j;
}
if ($useExt) {
$zval = symfony_zval_info($k, $step);
$zval = symfony_zval_info($k, $refs);
} else {
$step[$k] = $cookie;
if ($zval['zval_isref'] = $queue[$i][$k] === $cookie) {
$refs[$k] = $cookie;
if ($zval['zval_isref'] = $vals[$k] === $cookie) {
$zval['zval_hash'] = $v instanceof Stub ? spl_object_hash($v) : null;
}
$zval['type'] = gettype($v);
}
if ($zval['zval_isref']) {
$queue[$i][$k] = &$stub; // Break hard references to make $queue completely
$vals[$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);
$vals[$k] = $useExt ? ($v = $hardRefs[$zval['zval_hash']]) : ($refs[$k] = $v);
if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) {
++$v->value->refCount;
}
@@ -204,18 +209,18 @@ class VarCloner extends AbstractCloner
if (isset($stub)) {
if ($zval['zval_isref']) {
if ($useExt) {
$queue[$i][$k] = $hardRefs[$zval['zval_hash']] = $v = new Stub();
$vals[$k] = $hardRefs[$zval['zval_hash']] = $v = new Stub();
$v->value = $stub;
} else {
$step[$k] = new Stub();
$step[$k]->value = $stub;
$h = spl_object_hash($step[$k]);
$queue[$i][$k] = $hardRefs[$h] = &$step[$k];
$refs[$k] = new Stub();
$refs[$k]->value = $stub;
$h = spl_object_hash($refs[$k]);
$vals[$k] = $hardRefs[$h] = &$refs[$k];
$values[$h] = $v;
}
$queue[$i][$k]->handle = ++$refs;
$vals[$k]->handle = ++$refsCounter;
} else {
$queue[$i][$k] = $stub;
$vals[$k] = $stub;
}
if ($a) {
@@ -243,19 +248,38 @@ class VarCloner extends AbstractCloner
$stub = $a = null;
} elseif ($zval['zval_isref']) {
if ($useExt) {
$queue[$i][$k] = $hardRefs[$zval['zval_hash']] = new Stub();
$queue[$i][$k]->value = $v;
$vals[$k] = $hardRefs[$zval['zval_hash']] = new Stub();
$vals[$k]->value = $v;
} else {
$step[$k] = $queue[$i][$k] = new Stub();
$step[$k]->value = $v;
$h = spl_object_hash($step[$k]);
$hardRefs[$h] = &$step[$k];
$refs[$k] = $vals[$k] = new Stub();
$refs[$k]->value = $v;
$h = spl_object_hash($refs[$k]);
$hardRefs[$h] = &$refs[$k];
$values[$h] = $v;
}
$queue[$i][$k]->handle = ++$refs;
$vals[$k]->handle = ++$refsCounter;
}
}
if ($fromObjCast) {
$refs = $vals;
$vals = array();
$j = -1;
foreach ($queue[$i] as $k => $v) {
foreach (array($k => $v) as $a => $v) {
}
if ($a !== $k) {
$vals = (object) $vals;
$vals->{$k} = $refs[++$j];
$vals = (array) $vals;
} else {
$vals[$k] = $refs[++$j];
}
}
}
$queue[$i] = $vals;
if (isset($arrayRefs[$i])) {
if ($indexed) {
$arrayRefs[$i]->class = Stub::ARRAY_INDEXED;
@@ -291,7 +315,7 @@ class VarCloner extends AbstractCloner
if (!empty($frame['line'])) {
ob_start();
debug_zval_dump($obj);
self::$hashMask = substr(ob_get_clean(), 17);
self::$hashMask = (int) substr(ob_get_clean(), 17);
}
}

View File

@@ -32,8 +32,8 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
private $charset;
/**
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput.
* @param string $charset The default character encoding to use for non-UTF8 strings.
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput
* @param string $charset The default character encoding to use for non-UTF8 strings
*/
public function __construct($output = null, $charset = null)
{
@@ -49,9 +49,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
/**
* Sets the output destination of the dumps.
*
* @param callable|resource|string $output A line dumper callable, an opened stream or an output path.
* @param callable|resource|string $output A line dumper callable, an opened stream or an output path
*
* @return callable|resource|string The previous output destination.
* @return callable|resource|string The previous output destination
*/
public function setOutput($output)
{
@@ -74,9 +74,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
/**
* Sets the default character encoding to use for non-UTF8 strings.
*
* @param string $charset The default character encoding to use for non-UTF8 strings.
* @param string $charset The default character encoding to use for non-UTF8 strings
*
* @return string The previous charset.
* @return string The previous charset
*/
public function setCharset($charset)
{
@@ -93,9 +93,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
/**
* Sets the indentation pad string.
*
* @param string $pad A string the will be prepended to dumped lines, repeated by nesting level.
* @param string $pad A string the will be prepended to dumped lines, repeated by nesting level
*
* @return string The indent pad.
* @return string The indent pad
*/
public function setIndentPad($pad)
{
@@ -108,8 +108,8 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
/**
* Dumps a Data object.
*
* @param Data $data A Data object.
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path.
* @param Data $data A Data object
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path
*/
public function dump(Data $data, $output = null)
{
@@ -136,7 +136,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
/**
* Dumps the current line.
*
* @param int $depth The recursive depth in the dumped structure for the line being dumped.
* @param int $depth The recursive depth in the dumped structure for the line being dumped
*/
protected function dumpLine($depth)
{
@@ -147,8 +147,8 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
/**
* Generic line dumper callback.
*
* @param string $line The line to write.
* @param int $depth The recursive depth in the dumped structure.
* @param string $line The line to write
* @param int $depth The recursive depth in the dumped structure
*/
protected function echoLine($line, $depth, $indentPad)
{
@@ -160,9 +160,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
/**
* Converts a non-UTF-8 string to UTF-8.
*
* @param string $s The non-UTF-8 string to convert.
* @param string $s The non-UTF-8 string to convert
*
* @return string The string converted to UTF-8.
* @return string The string converted to UTF-8
*/
protected function utf8Encode($s)
{

View File

@@ -97,7 +97,7 @@ class CliDumper extends AbstractDumper
/**
* Configures styles.
*
* @param array $styles A map of style names to style definitions.
* @param array $styles A map of style names to style definitions
*/
public function setStyles(array $styles)
{
@@ -280,9 +280,9 @@ class CliDumper extends AbstractDumper
/**
* Dumps an ellipsis for cut children.
*
* @param Cursor $cursor The Cursor position in the dump.
* @param bool $hasChild When the dump of the hash has child item.
* @param int $cut The number of items the hash has been cut by.
* @param Cursor $cursor The Cursor position in the dump
* @param bool $hasChild When the dump of the hash has child item
* @param int $cut The number of items the hash has been cut by
*/
protected function dumpEllipsis(Cursor $cursor, $hasChild, $cut)
{
@@ -300,7 +300,7 @@ class CliDumper extends AbstractDumper
/**
* Dumps a key in a hash structure.
*
* @param Cursor $cursor The Cursor position in the dump.
* @param Cursor $cursor The Cursor position in the dump
*/
protected function dumpKey(Cursor $cursor)
{
@@ -368,11 +368,11 @@ class CliDumper extends AbstractDumper
/**
* Decorates a value with some style.
*
* @param string $style The type of style being applied.
* @param string $value The value being styled.
* @param array $attr Optional context information.
* @param string $style The type of style being applied
* @param string $value The value being styled
* @param array $attr Optional context information
*
* @return string The value with style decoration.
* @return string The value with style decoration
*/
protected function style($style, $value, $attr = array())
{
@@ -412,7 +412,7 @@ class CliDumper extends AbstractDumper
}
/**
* @return bool Tells if the current output stream supports ANSI colors or not.
* @return bool Tells if the current output stream supports ANSI colors or not
*/
protected function supportsColors()
{

View File

@@ -23,7 +23,7 @@ interface DataDumperInterface
/**
* Dumps a Data object.
*
* @param Data $data A Data object.
* @param Data $data A Data object
*/
public function dump(Data $data);
}

View File

@@ -78,7 +78,7 @@ class HtmlDumper extends CliDumper
/**
* Sets an HTML header that will be dumped once in the output stream.
*
* @param string $header An HTML string.
* @param string $header An HTML string
*/
public function setDumpHeader($header)
{
@@ -88,8 +88,8 @@ class HtmlDumper extends CliDumper
/**
* Sets an HTML prefix and suffix that will encapse every single dump.
*
* @param string $prefix The prepended HTML string.
* @param string $suffix The appended HTML string.
* @param string $prefix The prepended HTML string
* @param string $suffix The appended HTML string
*/
public function setDumpBoundaries($prefix, $suffix)
{

View File

@@ -210,8 +210,8 @@ array:2 [
executing: {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo(): {
%sGeneratorDemo.php:10: """
yield 1;\n
}\n
yield 1;\n
}\n
\n
"""
}

View File

@@ -128,6 +128,45 @@ EOTXT
);
}
public function testJsonCast()
{
$var = (array) json_decode('{"0":{},"1":null}');
foreach ($var as &$v) {
}
$var[] = &$v;
$var[''] = 2;
$this->assertDumpMatchesFormat(
<<<EOTXT
array:4 [
"0" => {}
"1" => &1 null
0 => &1 null
"" => 2
]
EOTXT
,
$var
);
}
public function testObjectCast()
{
$var = (object) array(1 => 1);
$var->{1} = 2;
$this->assertDumpMatchesFormat(
<<<EOTXT
{
+1: 1
+"1": 2
}
EOTXT
,
$var
);
}
public function testClosedResource()
{
if (defined('HHVM_VERSION') && HHVM_VERSION_ID < 30600) {
@@ -195,7 +234,7 @@ EOTXT
$twig = <<<EOTXT
foo.twig:2: """
foo bar\\n
twig source\\n
twig source\\n
\\n
"""

View File

@@ -29,6 +29,6 @@ class __TwigTemplate_VarDumperFixture_u75a09 extends Twig_Template
return array (19 => 2);
}
}
/* foo bar*/
/* foo bar*/
/* twig source*/
/* */

View File

@@ -135,6 +135,72 @@ EOTXT;
$this->assertStringMatchesFormat($expected, print_r($clone, true));
}
public function testJsonCast()
{
$data = (array) json_decode('{"1":{}}');
$cloner = new VarCloner();
$clone = $cloner->cloneVar($data);
$expected = <<<'EOTXT'
object(Symfony\Component\VarDumper\Cloner\Data)#%i (4) {
["data":"Symfony\Component\VarDumper\Cloner\Data":private]=>
array(2) {
[0]=>
array(1) {
[0]=>
object(Symfony\Component\VarDumper\Cloner\Stub)#%i (7) {
["type"]=>
string(5) "array"
["class"]=>
string(5) "assoc"
["value"]=>
int(1)
["cut"]=>
int(0)
["handle"]=>
int(0)
["refCount"]=>
int(0)
["position"]=>
int(1)
}
}
[1]=>
array(1) {
["1"]=>
object(Symfony\Component\VarDumper\Cloner\Stub)#%i (7) {
["type"]=>
string(6) "object"
["class"]=>
string(8) "stdClass"
["value"]=>
NULL
["cut"]=>
int(0)
["handle"]=>
int(%i)
["refCount"]=>
int(0)
["position"]=>
int(0)
}
}
}
["maxDepth":"Symfony\Component\VarDumper\Cloner\Data":private]=>
int(20)
["maxItemsPerDepth":"Symfony\Component\VarDumper\Cloner\Data":private]=>
int(-1)
["useRefHandles":"Symfony\Component\VarDumper\Cloner\Data":private]=>
int(-1)
}
EOTXT;
ob_start();
var_dump($clone);
$this->assertStringMatchesFormat($expected, ob_get_clean());
}
public function testCaster()
{
$cloner = new VarCloner(array(