修复华为云存储报错
This commit is contained in:
@@ -27,51 +27,51 @@ namespace Obs\Internal\Common;
|
||||
class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInterface
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct(array $data = [])
|
||||
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function count()
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->data);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
return new \ArrayIterator($this->data);
|
||||
}
|
||||
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
|
||||
public function clear()
|
||||
{
|
||||
$this->data = [];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAll(array $keys = null)
|
||||
|
||||
public function getAll(?array $keys = null)
|
||||
{
|
||||
return $keys ? array_intersect_key($this->data, array_flip($keys)) : $this->data;
|
||||
}
|
||||
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
return isset($this->data[$key]) ? $this->data[$key] : null;
|
||||
}
|
||||
|
||||
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->data[$key] = $value;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function add($key, $value)
|
||||
{
|
||||
if (!array_key_exists($key, $this->data)) {
|
||||
@@ -81,27 +81,27 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
|
||||
} else {
|
||||
$this->data[$key] = [$this->data[$key], $value];
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function remove($key)
|
||||
{
|
||||
unset($this->data[$key]);
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function getKeys()
|
||||
{
|
||||
return array_keys($this->data);
|
||||
}
|
||||
|
||||
|
||||
public function hasKey($key)
|
||||
{
|
||||
return array_key_exists($key, $this->data);
|
||||
}
|
||||
|
||||
|
||||
public function keySearch($key)
|
||||
{
|
||||
foreach (array_keys($this->data) as $k) {
|
||||
@@ -109,32 +109,32 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
|
||||
return $k;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function hasValue($value)
|
||||
{
|
||||
return array_search($value, $this->data);
|
||||
}
|
||||
|
||||
public function replace(array $data)
|
||||
|
||||
public function replace(?array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function merge($data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->add($key, $value);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function overwriteWith($data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
@@ -144,20 +144,20 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function map(\Closure $closure, array $context = [], $static = true)
|
||||
|
||||
public function map(\Closure $closure, ?array $context = [], $static = true)
|
||||
{
|
||||
$collection = $static ? new static() : new self();
|
||||
foreach ($this as $key => $value) {
|
||||
$collection->add($key, $closure($key, $value, $context));
|
||||
}
|
||||
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
|
||||
public function filter(\Closure $closure, $static = true)
|
||||
{
|
||||
$collection = ($static) ? new static() : new self();
|
||||
@@ -166,33 +166,33 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
|
||||
$collection->add($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->data[$offset]);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
|
||||
public function offsetGet($offset): mixed
|
||||
{
|
||||
return isset($this->data[$offset]) ? $this->data[$offset] : null;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
unset($this->data[$offset]);
|
||||
}
|
||||
|
||||
|
||||
public function setPath($path, $value)
|
||||
{
|
||||
$current =& $this->data;
|
||||
$current = &$this->data;
|
||||
$queue = explode('/', $path);
|
||||
while (null !== ($key = array_shift($queue))) {
|
||||
if (!is_array($current)) {
|
||||
@@ -200,28 +200,28 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
|
||||
} elseif (!$queue) {
|
||||
$current[$key] = $value;
|
||||
} elseif (isset($current[$key])) {
|
||||
$current =& $current[$key];
|
||||
$current = &$current[$key];
|
||||
} else {
|
||||
$current[$key] = [];
|
||||
$current =& $current[$key];
|
||||
$current = &$current[$key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function getPath($path, $separator = '/', $data = null)
|
||||
{
|
||||
if ($data === null) {
|
||||
$data =& $this->data;
|
||||
$data = &$this->data;
|
||||
}
|
||||
|
||||
|
||||
$path = is_array($path) ? $path : explode($separator, $path);
|
||||
while (null !== ($part = array_shift($path))) {
|
||||
if (!is_array($data)) {
|
||||
return null;
|
||||
} elseif (isset($data[$part])) {
|
||||
$data =& $data[$part];
|
||||
$data = &$data[$part];
|
||||
} elseif ($part != '*') {
|
||||
return null;
|
||||
} else {
|
||||
@@ -237,10 +237,10 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$output = 'Debug output of ';
|
||||
@@ -248,10 +248,10 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
|
||||
$output = str_repeat('=', strlen($output)) . "\n" . $output . "\n" . str_repeat('=', strlen($output)) . "\n\n";
|
||||
$output .= "Model data\n-----------\n\n";
|
||||
$output .= "This data can be retrieved from the model object using the get() method of the model "
|
||||
. "(e.g. \$model->get(\$key)) or accessing the model like an associative array (e.g. \$model['key']).\n\n";
|
||||
. "(e.g. \$model->get(\$key)) or accessing the model like an associative array (e.g. \$model['key']).\n\n";
|
||||
$lines = array_slice(explode("\n", trim(print_r($this->toArray(), true))), 2, -1);
|
||||
$output .= implode("\n", $lines);
|
||||
|
||||
|
||||
return $output . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
$this->maxHandles = $maxHandles;
|
||||
}
|
||||
|
||||
public function create(RequestInterface $request, array $options): EasyHandle
|
||||
public function create(?RequestInterface $request, ?array $options): EasyHandle
|
||||
{
|
||||
if (isset($options['curl']['body_as_string'])) {
|
||||
$options['_body_as_string'] = $options['curl']['body_as_string'];
|
||||
@@ -85,7 +85,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function release(EasyHandle $easy): void
|
||||
public function release(?EasyHandle $easy): void
|
||||
{
|
||||
$resource = $easy->handle;
|
||||
unset($easy->handle);
|
||||
@@ -102,7 +102,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function getDefaultConf(EasyHandle $easy)
|
||||
private function getDefaultConf(?EasyHandle $easy)
|
||||
{
|
||||
$conf = [
|
||||
'_headers' => $easy->request->getHeaders(),
|
||||
@@ -129,7 +129,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
return $conf;
|
||||
}
|
||||
|
||||
private function applyMethod(EasyHandle $easy, array &$conf)
|
||||
private function applyMethod(?EasyHandle $easy, ?array &$conf)
|
||||
{
|
||||
$body = $easy->request->getBody();
|
||||
$size = $body->getSize();
|
||||
@@ -155,7 +155,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function applyBody(RequestInterface $request, array $options, array &$conf)
|
||||
private function applyBody(?RequestInterface $request, ?array $options, ?array &$conf)
|
||||
{
|
||||
$size = $request->hasHeader('Content-Length')
|
||||
? (int) $request->getHeaderLine('Content-Length')
|
||||
@@ -209,7 +209,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function applyHeaders(EasyHandle $easy, array &$conf)
|
||||
private function applyHeaders(?EasyHandle $easy, ?array &$conf)
|
||||
{
|
||||
foreach ($conf['_headers'] as $name => $values) {
|
||||
foreach ($values as $value) {
|
||||
@@ -223,7 +223,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function removeHeader($name, array &$options)
|
||||
private function removeHeader($name, ?array &$options)
|
||||
{
|
||||
foreach (array_keys($options['_headers']) as $key) {
|
||||
if (!strcasecmp($key, $name)) {
|
||||
@@ -233,7 +233,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function applyHandlerOptions(EasyHandle $easy, array &$conf)
|
||||
private function applyHandlerOptions(?EasyHandle $easy, ?array &$conf)
|
||||
{
|
||||
$options = $easy->options;
|
||||
if (isset($options['verify'])) {
|
||||
@@ -381,7 +381,7 @@ class SdkCurlFactory implements CurlFactoryInterface
|
||||
}
|
||||
|
||||
|
||||
private function createHeaderFn(EasyHandle $easy)
|
||||
private function createHeaderFn(?EasyHandle $easy)
|
||||
{
|
||||
if (isset($easy->options['on_headers'])) {
|
||||
$onHeaders = $easy->options['on_headers'];
|
||||
|
||||
@@ -38,7 +38,7 @@ class SdkStreamHandler
|
||||
{
|
||||
private $lastHeaders = [];
|
||||
|
||||
public function __invoke(RequestInterface $request, array $options)
|
||||
public function __invoke(?RequestInterface $request, ?array $options)
|
||||
{
|
||||
if (isset($options['delay'])) {
|
||||
usleep($options['delay'] * 1000);
|
||||
@@ -77,10 +77,10 @@ class SdkStreamHandler
|
||||
}
|
||||
|
||||
private function invokeStats(
|
||||
array $options,
|
||||
RequestInterface $request,
|
||||
?array $options,
|
||||
?RequestInterface $request,
|
||||
$startTime,
|
||||
ResponseInterface $response = null,
|
||||
?ResponseInterface $response = null,
|
||||
$error = null
|
||||
) {
|
||||
if (isset($options['on_stats'])) {
|
||||
@@ -96,8 +96,8 @@ class SdkStreamHandler
|
||||
}
|
||||
|
||||
private function createResponse(
|
||||
RequestInterface $request,
|
||||
array $options,
|
||||
?RequestInterface $request,
|
||||
?array $options,
|
||||
$stream,
|
||||
$startTime
|
||||
) {
|
||||
@@ -141,7 +141,7 @@ class SdkStreamHandler
|
||||
return new FulfilledPromise($response);
|
||||
}
|
||||
|
||||
private function createSink(StreamInterface $stream, array $options)
|
||||
private function createSink(StreamInterface $stream, ?array $options)
|
||||
{
|
||||
if (!empty($options['stream'])) {
|
||||
return $stream;
|
||||
@@ -156,7 +156,7 @@ class SdkStreamHandler
|
||||
: \GuzzleHttp\Psr7\Utils::streamFor($sink);
|
||||
}
|
||||
|
||||
private function checkDecode(array $options, array $headers, $stream)
|
||||
private function checkDecode(?array $options, ?array $headers, $stream)
|
||||
{
|
||||
if (!empty($options['decode_content'])) {
|
||||
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
|
||||
@@ -232,7 +232,7 @@ class SdkStreamHandler
|
||||
return $resource;
|
||||
}
|
||||
|
||||
private function createStream(RequestInterface $request, array $options)
|
||||
private function createStream(?RequestInterface $request, ?array $options)
|
||||
{
|
||||
static $methods;
|
||||
if (!$methods) {
|
||||
@@ -309,7 +309,7 @@ class SdkStreamHandler
|
||||
);
|
||||
}
|
||||
|
||||
private function resolveHost(RequestInterface $request, array $options)
|
||||
private function resolveHost(?RequestInterface $request, ?array $options)
|
||||
{
|
||||
$uri = $request->getUri();
|
||||
|
||||
@@ -332,7 +332,7 @@ class SdkStreamHandler
|
||||
return $uri;
|
||||
}
|
||||
|
||||
private function getDefaultContext(RequestInterface $request)
|
||||
private function getDefaultContext(?RequestInterface $request)
|
||||
{
|
||||
$headers = '';
|
||||
foreach ($request->getHeaders() as $name => $value) {
|
||||
@@ -365,7 +365,7 @@ class SdkStreamHandler
|
||||
return $context;
|
||||
}
|
||||
|
||||
private function add_proxy(RequestInterface $request, &$options, $value, &$params)
|
||||
private function add_proxy(?RequestInterface $request, &$options, $value, &$params)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
$options['http']['proxy'] = $value;
|
||||
@@ -384,14 +384,14 @@ class SdkStreamHandler
|
||||
}
|
||||
}
|
||||
|
||||
private function add_timeout(RequestInterface $request, &$options, $value, &$params)
|
||||
private function add_timeout(?RequestInterface $request, &$options, $value, &$params)
|
||||
{
|
||||
if ($value > 0) {
|
||||
$options['http']['timeout'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
private function add_verify(RequestInterface $request, &$options, $value, &$params)
|
||||
private function add_verify(?RequestInterface $request, &$options, $value, &$params)
|
||||
{
|
||||
if ($value === true) {
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
@@ -415,7 +415,7 @@ class SdkStreamHandler
|
||||
$options['ssl']['allow_self_signed'] = false;
|
||||
}
|
||||
|
||||
private function add_cert(RequestInterface $request, &$options, $value, &$params)
|
||||
private function add_cert(?RequestInterface $request, &$options, $value, &$params)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$options['ssl']['passphrase'] = $value[1];
|
||||
@@ -429,7 +429,7 @@ class SdkStreamHandler
|
||||
$options['ssl']['local_cert'] = $value;
|
||||
}
|
||||
|
||||
private function add_progress(RequestInterface $request, &$options, $value, &$params)
|
||||
private function add_progress(?RequestInterface $request, &$options, $value, &$params)
|
||||
{
|
||||
$this->addNotification(
|
||||
$params,
|
||||
@@ -441,7 +441,7 @@ class SdkStreamHandler
|
||||
);
|
||||
}
|
||||
|
||||
private function add_debug(RequestInterface $request, &$options, $value, &$params)
|
||||
private function add_debug(?RequestInterface $request, &$options, $value, &$params)
|
||||
{
|
||||
if ($value === false) {
|
||||
return;
|
||||
@@ -478,7 +478,7 @@ class SdkStreamHandler
|
||||
);
|
||||
}
|
||||
|
||||
private function addNotification(array &$params, callable $notify)
|
||||
private function addNotification(?array &$params, callable $notify)
|
||||
{
|
||||
if (!isset($params['notification'])) {
|
||||
$params['notification'] = $notify;
|
||||
@@ -490,7 +490,7 @@ class SdkStreamHandler
|
||||
}
|
||||
}
|
||||
|
||||
private function callArray(array $functions)
|
||||
private function callArray(?array $functions)
|
||||
{
|
||||
return function () use ($functions) {
|
||||
$args = func_get_args();
|
||||
|
||||
Reference in New Issue
Block a user