upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -29,11 +29,15 @@ abstract class AbstractCloner implements ClonerInterface
'Symfony\Component\VarDumper\Caster\ConstStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'],
'Symfony\Component\VarDumper\Caster\EnumStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castEnum'],
'Fiber' => ['Symfony\Component\VarDumper\Caster\FiberCaster', 'castFiber'],
'Closure' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClosure'],
'Generator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castGenerator'],
'ReflectionType' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castType'],
'ReflectionAttribute' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castAttribute'],
'ReflectionGenerator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReflectionGenerator'],
'ReflectionClass' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClass'],
'ReflectionClassConstant' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClassConstant'],
'ReflectionFunctionAbstract' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castFunctionAbstract'],
'ReflectionMethod' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castMethod'],
'ReflectionParameter' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castParameter'],
@@ -76,13 +80,18 @@ abstract class AbstractCloner implements ClonerInterface
'ErrorException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castErrorException'],
'Exception' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castException'],
'Error' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castError'],
'Symfony\Bridge\Monolog\Logger' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
'Symfony\Component\DependencyInjection\ContainerInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
'Symfony\Component\EventDispatcher\EventDispatcherInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
'Symfony\Component\HttpClient\AmpHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
'Symfony\Component\HttpClient\CurlHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
'Symfony\Component\HttpClient\NativeHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
'Symfony\Component\HttpClient\Response\AmpResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'],
'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'],
'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'],
'Symfony\Component\HttpFoundation\Request' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castRequest'],
'Symfony\Component\Uid\Ulid' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castUlid'],
'Symfony\Component\Uid\Uuid' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castUuid'],
'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'],
@@ -171,14 +180,34 @@ abstract class AbstractCloner implements ClonerInterface
'XmlParser' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'],
':xml' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'],
'RdKafka' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castRdKafka'],
'RdKafka\Conf' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castConf'],
'RdKafka\KafkaConsumer' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castKafkaConsumer'],
'RdKafka\Metadata\Broker' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castBrokerMetadata'],
'RdKafka\Metadata\Collection' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castCollectionMetadata'],
'RdKafka\Metadata\Partition' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castPartitionMetadata'],
'RdKafka\Metadata\Topic' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopicMetadata'],
'RdKafka\Message' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castMessage'],
'RdKafka\Topic' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopic'],
'RdKafka\TopicPartition' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopicPartition'],
'RdKafka\TopicConf' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopicConf'],
];
protected $maxItems = 2500;
protected $maxString = -1;
protected $minDepth = 1;
/**
* @var array<string, list<callable>>
*/
private $casters = [];
/**
* @var callable|null
*/
private $prevErrorHandler;
private $classInfo = [];
private $filter = 0;
@@ -214,33 +243,27 @@ abstract class AbstractCloner implements ClonerInterface
/**
* Sets the maximum number of items to clone past the minimum depth in nested structures.
*
* @param int $maxItems
*/
public function setMaxItems($maxItems)
public function setMaxItems(int $maxItems)
{
$this->maxItems = (int) $maxItems;
$this->maxItems = $maxItems;
}
/**
* Sets the maximum cloned length for strings.
*
* @param int $maxString
*/
public function setMaxString($maxString)
public function setMaxString(int $maxString)
{
$this->maxString = (int) $maxString;
$this->maxString = $maxString;
}
/**
* Sets the minimum tree depth where we are guaranteed to clone all the items. After this
* depth is reached, only setMaxItems items will be cloned.
*
* @param int $minDepth
*/
public function setMinDepth($minDepth)
public function setMinDepth(int $minDepth)
{
$this->minDepth = (int) $minDepth;
$this->minDepth = $minDepth;
}
/**
@@ -249,9 +272,9 @@ abstract class AbstractCloner implements ClonerInterface
* @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
*/
public function cloneVar($var, $filter = 0)
public function cloneVar($var, int $filter = 0)
{
$this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) {
if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) {
@@ -286,7 +309,7 @@ abstract class AbstractCloner implements ClonerInterface
*
* @param mixed $var Any PHP variable
*
* @return array The cloned variable represented in an array
* @return array
*/
abstract protected function doClone($var);
@@ -295,9 +318,9 @@ abstract class AbstractCloner implements ClonerInterface
*
* @param bool $isNested True if the object is nested in the dumped structure
*
* @return array The object casted as array
* @return array
*/
protected function castObject(Stub $stub, $isNested)
protected function castObject(Stub $stub, bool $isNested)
{
$obj = $stub->value;
$class = $stub->class;
@@ -354,9 +377,9 @@ abstract class AbstractCloner implements ClonerInterface
*
* @param bool $isNested True if the object is nested in the dumped structure
*
* @return array The resource casted as array
* @return array
*/
protected function castResource(Stub $stub, $isNested)
protected function castResource(Stub $stub, bool $isNested)
{
$a = [];
$res = $stub->value;

View File

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

View File

@@ -36,7 +36,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
}
/**
* @return string|null The type of the value
* @return string|null
*/
public function getType()
{
@@ -65,9 +65,11 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
}
/**
* Returns a native representation of the original value.
*
* @param array|bool $recursive Whether values should be resolved recursively or not
*
* @return string|int|float|bool|array|Data[]|null A native representation of the original value
* @return string|int|float|bool|array|Data[]|null
*/
public function getValue($recursive = false)
{
@@ -124,13 +126,13 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
public function getIterator()
{
if (!\is_array($value = $this->getValue())) {
throw new \LogicException(sprintf('"%s" object holds non-iterable type "%s".', self::class, \gettype($value)));
throw new \LogicException(sprintf('"%s" object holds non-iterable type "%s".', self::class, get_debug_type($value)));
}
yield from $value;
}
public function __get($key)
public function __get(string $key)
{
if (null !== $data = $this->seek($key)) {
$item = $this->getStub($data->data[$data->position][$data->key]);
@@ -144,7 +146,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
/**
* @return bool
*/
public function __isset($key)
public function __isset(string $key)
{
return null !== $this->seek($key);
}
@@ -202,14 +204,12 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
/**
* Returns a depth limited clone of $this.
*
* @param int $maxDepth The max dumped depth level
*
* @return static
*/
public function withMaxDepth($maxDepth)
public function withMaxDepth(int $maxDepth)
{
$data = clone $this;
$data->maxDepth = (int) $maxDepth;
$data->maxDepth = $maxDepth;
return $data;
}
@@ -217,14 +217,12 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
/**
* Limits the number of elements per depth level.
*
* @param int $maxItemsPerDepth The max number of items dumped per depth level
*
* @return static
*/
public function withMaxItemsPerDepth($maxItemsPerDepth)
public function withMaxItemsPerDepth(int $maxItemsPerDepth)
{
$data = clone $this;
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;
$data->maxItemsPerDepth = $maxItemsPerDepth;
return $data;
}
@@ -236,7 +234,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
*
* @return static
*/
public function withRefHandles($useRefHandles)
public function withRefHandles(bool $useRefHandles)
{
$data = clone $this;
$data->useRefHandles = $useRefHandles ? -1 : 0;
@@ -260,7 +258,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
*
* @param string|int $key The key to seek to
*
* @return static|null Null if the key is not set
* @return static|null
*/
public function seek($key)
{

View File

@@ -24,7 +24,7 @@ interface DumperInterface
* @param string $type The PHP type of the value being dumped
* @param string|int|float|bool $value The scalar value being dumped
*/
public function dumpScalar(Cursor $cursor, $type, $value);
public function dumpScalar(Cursor $cursor, string $type, $value);
/**
* Dumps a string.
@@ -33,7 +33,7 @@ interface DumperInterface
* @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);
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut);
/**
* Dumps while entering an hash.
@@ -42,7 +42,7 @@ interface DumperInterface
* @param string|int $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);
public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild);
/**
* Dumps while leaving an hash.
@@ -52,5 +52,5 @@ interface DumperInterface
* @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);
public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut);
}

View File

@@ -27,13 +27,12 @@ class VarCloner extends AbstractCloner
$len = 1; // Length of $queue
$pos = 0; // Number of cloned items past the minimum depth
$refsCounter = 0; // Hard references counter
$queue = [[$var]]; // This breadth-first queue is the return value
$indexedArrays = []; // Map of queue indexes that hold numerically indexed arrays
$hardRefs = []; // Map of original zval ids to stub objects
$objRefs = []; // Map of original object handles to their stub object counterpart
$objects = []; // Keep a ref to objects to ensure their handle cannot be reused while cloning
$resRefs = []; // Map of original resource handles to their stub object counterpart
$values = []; // Map of stub objects' ids to original values
$queue = [[$var]]; // This breadth-first queue is the return value
$hardRefs = []; // Map of original zval ids to stub objects
$objRefs = []; // Map of original object handles to their stub object counterpart
$objects = []; // Keep a ref to objects to ensure their handle cannot be reused while cloning
$resRefs = []; // Map of original resource handles to their stub object counterpart
$values = []; // Map of stub objects' ids to original values
$maxItems = $this->maxItems;
$maxString = $this->maxString;
$minDepth = $this->minDepth;
@@ -63,21 +62,6 @@ class VarCloner extends AbstractCloner
}
$refs = $vals = $queue[$i];
if (\PHP_VERSION_ID < 70200 && empty($indexedArrays[$i])) {
// see https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts
foreach ($vals as $k => $v) {
if (\is_int($k)) {
continue;
}
foreach ([$k => true] as $gk => $gv) {
}
if ($gk !== $k) {
$fromObjCast = true;
$refs = $vals = array_values($queue[$i]);
break;
}
}
}
foreach ($vals as $k => $v) {
// $v is the original value or a stub object in case of hard references
@@ -116,7 +100,7 @@ class VarCloner extends AbstractCloner
$values[$h] = $v;
}
}
// Create $stub when the original value $v can not be used directly
// Create $stub when the original value $v cannot be used directly
// If $v is a nested structure, put that structure in array $a
switch (true) {
case null === $v:
@@ -155,51 +139,54 @@ class VarCloner extends AbstractCloner
continue 2;
}
$stub = $arrayStub;
if (\PHP_VERSION_ID >= 80100) {
$stub->class = array_is_list($v) ? Stub::ARRAY_INDEXED : Stub::ARRAY_ASSOC;
$a = $v;
break;
}
$stub->class = Stub::ARRAY_INDEXED;
$j = -1;
foreach ($v as $gk => $gv) {
if ($gk !== ++$j) {
$stub->class = Stub::ARRAY_ASSOC;
$a = $v;
$a[$gid] = true;
break;
}
}
$a = $v;
if (Stub::ARRAY_ASSOC === $stub->class) {
// Copies of $GLOBALS have very strange behavior,
// let's detect them with some black magic
if (\PHP_VERSION_ID < 80100 && ($a[$gid] = true) && isset($v[$gid])) {
unset($v[$gid]);
$a = [];
foreach ($v as $gk => &$gv) {
if ($v === $gv && (\PHP_VERSION_ID < 70400 || !isset($hardRefs[\ReflectionReference::fromArrayElement($v, $gk)->getId()]))) {
unset($v);
$v = new Stub();
$v->value = [$v->cut = \count($gv), Stub::TYPE_ARRAY => 0];
$v->handle = -1;
if (\PHP_VERSION_ID >= 70400) {
$gv = &$a[$gk];
$hardRefs[\ReflectionReference::fromArrayElement($a, $gk)->getId()] = &$gv;
} else {
$gv = &$hardRefs[spl_object_id($v)];
}
$gv = $v;
// Copies of $GLOBALS have very strange behavior,
// let's detect them with some black magic
if (isset($v[$gid])) {
unset($v[$gid]);
$a = [];
foreach ($v as $gk => &$gv) {
if ($v === $gv && (\PHP_VERSION_ID < 70400 || !isset($hardRefs[\ReflectionReference::fromArrayElement($v, $gk)->getId()]))) {
unset($v);
$v = new Stub();
$v->value = [$v->cut = \count($gv), Stub::TYPE_ARRAY => 0];
$v->handle = -1;
if (\PHP_VERSION_ID >= 70400) {
$gv = &$a[$gk];
$hardRefs[\ReflectionReference::fromArrayElement($a, $gk)->getId()] = &$gv;
} else {
$gv = &$hardRefs[spl_object_id($v)];
}
$a[$gk] = &$gv;
$gv = $v;
}
unset($gv);
} else {
$a = $v;
$a[$gk] = &$gv;
}
} elseif (\PHP_VERSION_ID < 70200) {
$indexedArrays[$len] = true;
unset($gv);
} else {
$a = $v;
}
break;
case \is_object($v):
case $v instanceof \__PHP_Incomplete_Class:
if (empty($objRefs[$h = spl_object_id($v)])) {
$stub = new Stub();
$stub->type = Stub::TYPE_OBJECT;