Update to laravel 7

This commit is contained in:
KodeStar
2022-03-10 11:54:29 +00:00
parent 61a5a1a8b0
commit f9a19fce91
7170 changed files with 274189 additions and 283773 deletions

View File

@@ -12,6 +12,7 @@
namespace Symfony\Component\VarDumper\Cloner;
use Symfony\Component\VarDumper\Caster\Caster;
use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
/**
* @author Nicolas Grekas <p@tchwork.com>
@@ -24,6 +25,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
private $maxDepth = 20;
private $maxItemsPerDepth = -1;
private $useRefHandles = -1;
private $context = [];
/**
* @param array $data An array as returned by ClonerInterface::cloneVar()
@@ -34,7 +36,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
}
/**
* @return string The type of the value
* @return string|null
*/
public function getType()
{
@@ -58,12 +60,16 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
if (Stub::TYPE_RESOURCE === $item->type) {
return $item->class.' resource';
}
return null;
}
/**
* @param bool $recursive Whether values should be resolved recursively or not
* Returns a native representation of the original value.
*
* @return string|int|float|bool|array|Data[]|null 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
*/
public function getValue($recursive = false)
{
@@ -104,54 +110,86 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
return $children;
}
/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return \count($this->getValue());
}
/**
* @return \Traversable
*/
#[\ReturnTypeWillChange]
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]);
return $item instanceof Stub || [] === $item ? $data : $item;
}
return null;
}
public function __isset($key)
/**
* @return bool
*/
public function __isset(string $key)
{
return null !== $this->seek($key);
}
/**
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return $this->__isset($key);
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->__get($key);
}
/**
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
throw new \BadMethodCallException(self::class.' objects are immutable.');
}
/**
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
throw new \BadMethodCallException(self::class.' objects are immutable.');
}
/**
* @return string
*/
public function __toString()
{
$value = $this->getValue();
@@ -166,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 self A clone of $this
* @return static
*/
public function withMaxDepth($maxDepth)
public function withMaxDepth(int $maxDepth)
{
$data = clone $this;
$data->maxDepth = (int) $maxDepth;
$data->maxDepth = $maxDepth;
return $data;
}
@@ -181,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 self A clone of $this
* @return static
*/
public function withMaxItemsPerDepth($maxItemsPerDepth)
public function withMaxItemsPerDepth(int $maxItemsPerDepth)
{
$data = clone $this;
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;
$data->maxItemsPerDepth = $maxItemsPerDepth;
return $data;
}
@@ -198,9 +232,9 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
*
* @param bool $useRefHandles False to hide global ref. handles
*
* @return self A clone of $this
* @return static
*/
public function withRefHandles($useRefHandles)
public function withRefHandles(bool $useRefHandles)
{
$data = clone $this;
$data->useRefHandles = $useRefHandles ? -1 : 0;
@@ -208,12 +242,23 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
return $data;
}
/**
* @return static
*/
public function withContext(array $context)
{
$data = clone $this;
$data->context = $context;
return $data;
}
/**
* Seeks to a specific key in nested data structures.
*
* @param string|int $key The key to seek to
*
* @return self|null A clone of $this or null if the key is not set
* @return static|null
*/
public function seek($key)
{
@@ -223,7 +268,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
$item = $item->value;
}
if (!($item = $this->getStub($item)) instanceof Stub || !$item->position) {
return;
return null;
}
$keys = [$key];
@@ -238,7 +283,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
case Stub::TYPE_RESOURCE:
break;
default:
return;
return null;
}
$data = null;
@@ -262,18 +307,26 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
public function dump(DumperInterface $dumper)
{
$refs = [0];
$this->dumpItem($dumper, new Cursor(), $refs, $this->data[$this->position][$this->key]);
$cursor = new Cursor();
if ($cursor->attr = $this->context[SourceContextProvider::class] ?? []) {
$cursor->attr['if_links'] = true;
$cursor->hashType = -1;
$dumper->dumpScalar($cursor, 'default', '^');
$cursor->attr = ['if_links' => true];
$dumper->dumpScalar($cursor, 'default', ' ');
$cursor->hashType = 0;
}
$this->dumpItem($dumper, $cursor, $refs, $this->data[$this->position][$this->key]);
}
/**
* 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 mixed $item A Stub object or the original value being dumped
*/
private function dumpItem($dumper, $cursor, &$refs, $item)
private function dumpItem(DumperInterface $dumper, Cursor $cursor, array &$refs, $item)
{
$cursor->refIndex = 0;
$cursor->softRefTo = $cursor->softRefHandle = $cursor->softRefCount = 0;
@@ -288,14 +341,14 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
}
} elseif (Stub::TYPE_REF === $item->type) {
if ($item->handle) {
if (!isset($refs[$r = $item->handle - (PHP_INT_MAX >> 1)])) {
if (!isset($refs[$r = $item->handle - (\PHP_INT_MAX >> 1)])) {
$cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0];
} else {
$firstSeen = false;
}
$cursor->hardRefTo = $refs[$r];
$cursor->hardRefHandle = $this->useRefHandles & $item->handle;
$cursor->hardRefCount = $item->refCount;
$cursor->hardRefCount = 0 < $item->handle ? $item->refCount : 0;
}
$cursor->attr = $item->attr;
$type = $item->class ?: \gettype($item->value);
@@ -356,7 +409,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
break;
default:
throw new \RuntimeException(sprintf('Unexpected Stub type: %s', $item->type));
throw new \RuntimeException(sprintf('Unexpected Stub type: "%s".', $item->type));
}
} elseif ('array' === $type) {
$dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false);
@@ -371,17 +424,9 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
/**
* 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 bool $dumpKeys Whether keys should be dumped or not
*
* @return int The final number of removed items
*/
private function dumpChildren($dumper, $parentCursor, &$refs, $children, $hashCut, $hashType, $dumpKeys)
private function dumpChildren(DumperInterface $dumper, Cursor $parentCursor, array &$refs, array $children, int $hashCut, int $hashType, bool $dumpKeys): int
{
$cursor = clone $parentCursor;
++$cursor->depth;