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

@@ -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);
}
}