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

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace GuzzleHttp\Psr7;
use Psr\Http\Message\StreamInterface;
@@ -13,15 +15,13 @@ use Psr\Http\Message\StreamInterface;
* returned by the provided callable is buffered internally until drained using
* the read() function of the PumpStream. The provided callable MUST return
* false when there is no more data to read.
*
* @final
*/
class PumpStream implements StreamInterface
final class PumpStream implements StreamInterface
{
/** @var callable */
/** @var callable|null */
private $source;
/** @var int */
/** @var int|null */
private $size;
/** @var int */
@@ -34,91 +34,95 @@ class PumpStream implements StreamInterface
private $buffer;
/**
* @param callable $source Source of the stream data. The callable MAY
* accept an integer argument used to control the
* amount of data to return. The callable MUST
* return a string when called, or false on error
* or EOF.
* @param array $options Stream options:
* - metadata: Hash of metadata to use with stream.
* - size: Size of the stream, if known.
* @param callable(int): (string|null|false) $source Source of the stream data. The callable MAY
* accept an integer argument used to control the
* amount of data to return. The callable MUST
* return a string when called, or false|null on error
* or EOF.
* @param array{size?: int, metadata?: array} $options Stream options:
* - metadata: Hash of metadata to use with stream.
* - size: Size of the stream, if known.
*/
public function __construct(callable $source, array $options = [])
{
$this->source = $source;
$this->size = isset($options['size']) ? $options['size'] : null;
$this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
$this->size = $options['size'] ?? null;
$this->metadata = $options['metadata'] ?? [];
$this->buffer = new BufferStream();
}
public function __toString()
public function __toString(): string
{
try {
return Utils::copyToString($this);
} catch (\Exception $e) {
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
return '';
}
}
public function close()
public function close(): void
{
$this->detach();
}
public function detach()
{
$this->tellPos = false;
$this->tellPos = 0;
$this->source = null;
return null;
}
public function getSize()
public function getSize(): ?int
{
return $this->size;
}
public function tell()
public function tell(): int
{
return $this->tellPos;
}
public function eof()
public function eof(): bool
{
return !$this->source;
return $this->source === null;
}
public function isSeekable()
public function isSeekable(): bool
{
return false;
}
public function rewind()
public function rewind(): void
{
$this->seek(0);
}
public function seek($offset, $whence = SEEK_SET)
public function seek($offset, $whence = SEEK_SET): void
{
throw new \RuntimeException('Cannot seek a PumpStream');
}
public function isWritable()
public function isWritable(): bool
{
return false;
}
public function write($string)
public function write($string): int
{
throw new \RuntimeException('Cannot write to a PumpStream');
}
public function isReadable()
public function isReadable(): bool
{
return true;
}
public function read($length)
public function read($length): string
{
$data = $this->buffer->read($length);
$readLen = strlen($data);
@@ -134,7 +138,7 @@ class PumpStream implements StreamInterface
return $data;
}
public function getContents()
public function getContents(): string
{
$result = '';
while (!$this->eof()) {
@@ -144,16 +148,21 @@ class PumpStream implements StreamInterface
return $result;
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function getMetadata($key = null)
{
if (!$key) {
return $this->metadata;
}
return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
return $this->metadata[$key] ?? null;
}
private function pump($length)
private function pump(int $length): void
{
if ($this->source) {
do {