From 54ec6723deb44e325782afd366eeec01ee29ac55 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 23 Mar 2016 15:30:47 +0100 Subject: Maj Library --- .../common/src/Common/Api/AbstractApi.php | 12 +++--- .../common/src/Common/Api/AbstractParams.php | 20 ++++----- .../common/src/Common/Api/ApiInterface.php | 2 +- .../common/src/Common/Api/Operation.php | 22 +++++----- .../common/src/Common/Api/Operator.php | 18 ++++---- .../common/src/Common/Api/OperatorInterface.php | 11 +++-- .../common/src/Common/Api/Parameter.php | 48 +++++++++++----------- .../common/src/Common/ArrayAccessTrait.php | 8 ++-- .../common/src/Common/Auth/AuthHandler.php | 7 +++- .../common/src/Common/Auth/Catalog.php | 4 +- .../common/src/Common/Auth/IdentityService.php | 4 +- .../php-opencloud/common/src/Common/Auth/Token.php | 6 +-- .../common/src/Common/Error/BadResponseError.php | 6 +-- .../common/src/Common/Error/BaseError.php | 2 +- .../common/src/Common/Error/Builder.php | 14 +++---- .../src/Common/Error/NotImplementedError.php | 2 +- .../common/src/Common/Error/UserInputError.php | 2 +- .../common/src/Common/HydratorStrategyTrait.php | 4 +- .../php-opencloud/common/src/Common/JsonPath.php | 13 +++--- .../common/src/Common/JsonSchema/JsonPatch.php | 18 ++++---- .../common/src/Common/JsonSchema/Schema.php | 15 ++++--- .../src/Common/Resource/AbstractResource.php | 24 ++++++----- .../common/src/Common/Resource/Creatable.php | 4 +- .../common/src/Common/Resource/Deletable.php | 2 +- .../common/src/Common/Resource/HasMetadata.php | 10 ++--- .../common/src/Common/Resource/HasWaiterTrait.php | 10 ++--- .../common/src/Common/Resource/Iterator.php | 2 +- .../common/src/Common/Resource/Listable.php | 2 +- .../src/Common/Resource/ResourceInterface.php | 2 +- .../common/src/Common/Resource/Retrievable.php | 2 +- .../common/src/Common/Resource/Updateable.php | 2 +- .../common/src/Common/Service/AbstractService.php | 2 +- .../common/src/Common/Service/Builder.php | 40 +++++++++--------- .../common/src/Common/Service/ServiceInterface.php | 2 +- .../common/src/Common/Transport/HandlerStack.php | 4 +- .../common/src/Common/Transport/JsonSerializer.php | 12 +++--- .../common/src/Common/Transport/Middleware.php | 20 +++++---- .../src/Common/Transport/RequestSerializer.php | 4 +- .../common/src/Common/Transport/Utils.php | 14 +++---- 39 files changed, 206 insertions(+), 190 deletions(-) (limited to 'server/vendor/php-opencloud/common/src/Common') diff --git a/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php b/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php index beee5e8..09988fd 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php @@ -1,4 +1,4 @@ - true]); } - protected function notRequired(array $param) + protected function notRequired(array $param): array { return array_merge($param, ['required' => false]); } - protected function query(array $param) + protected function query(array $param): array { return array_merge($param, ['location' => AbstractParams::QUERY]); } - protected function url(array $param) + protected function url(array $param): array { return array_merge($param, ['location' => AbstractParams::URL]); } - public function documented(array $param) + public function documented(array $param): array { return array_merge($param, ['required' => true]); } diff --git a/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php b/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php index 225e025..b21b3dd 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php @@ -1,4 +1,4 @@ - self::INT_TYPE, @@ -38,7 +38,7 @@ DESC ]; } - public function marker() + public function marker(): array { return [ 'type' => 'string', @@ -51,7 +51,7 @@ DESC ]; } - public function id($type) + public function id(string $type): array { return [ 'description' => sprintf("The unique ID, or identifier, for the %s", $type), @@ -60,7 +60,7 @@ DESC ]; } - public function idPath() + public function idPath(): array { return [ 'type' => self::STRING_TYPE, @@ -69,7 +69,7 @@ DESC ]; } - public function name($resource) + public function name(string $resource): array { return [ 'description' => sprintf("The name of the %s", $resource), @@ -79,7 +79,7 @@ DESC } - public function sortDir() + public function sortDir(): array { return [ 'type' => self::STRING_TYPE, @@ -89,7 +89,7 @@ DESC ]; } - public function sortKey() + public function sortKey(): array { return [ 'type' => self::STRING_TYPE, @@ -97,4 +97,4 @@ DESC 'description' => "Sorts by one or more sets of attribute and sort direction combinations.", ]; } -} +} \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php b/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php index d5d26a0..d4629dc 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php @@ -1,4 +1,4 @@ -path; } @@ -57,7 +55,7 @@ class Operation /** * @return string */ - public function getMethod() + public function getMethod(): string { return $this->method; } @@ -69,7 +67,7 @@ class Operation * * @return bool */ - public function hasParam($key) + public function hasParam(string $key): bool { return isset($this->params[$key]); } @@ -79,7 +77,7 @@ class Operation * * @return Parameter */ - public function getParam($name) + public function getParam(string $name) { return isset($this->params[$name]) ? $this->params[$name] : null; } @@ -87,9 +85,9 @@ class Operation /** * @return string */ - public function getJsonKey() + public function getJsonKey(): string { - return $this->jsonKey; + return $this->jsonKey ?: ''; } /** @@ -100,7 +98,7 @@ class Operation * * @return array */ - public static function toParamArray(array $data) + public static function toParamArray(array $data): array { $params = []; @@ -121,7 +119,7 @@ class Operation * @return bool TRUE if validation passes * @throws \Exception If validate fails */ - public function validate(array $userValues) + public function validate(array $userValues): bool { foreach ($this->params as $paramName => $param) { if (array_key_exists($paramName, $userValues)) { @@ -133,4 +131,4 @@ class Operation return true; } -} +} \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/src/Common/Api/Operator.php b/server/vendor/php-opencloud/common/src/Common/Api/Operator.php index 4325b69..5698779 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/Operator.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/Operator.php @@ -1,7 +1,9 @@ -validate($userValues); @@ -79,7 +81,7 @@ abstract class Operator implements OperatorInterface /** * {@inheritDoc} */ - public function execute(array $definition, array $userValues = []) + public function execute(array $definition, array $userValues = []): ResponseInterface { return $this->sendRequest($this->getOperation($definition), $userValues); } @@ -87,7 +89,7 @@ abstract class Operator implements OperatorInterface /** * {@inheritDoc} */ - public function executeAsync(array $definition, array $userValues = []) + public function executeAsync(array $definition, array $userValues = []): PromiseInterface { return $this->sendRequest($this->getOperation($definition), $userValues, true); } @@ -95,7 +97,7 @@ abstract class Operator implements OperatorInterface /** * {@inheritDoc} */ - public function model($class, $data = null) + public function model(string $class, $data = null): ResourceInterface { $model = new $class($this->client, $this->api); @@ -121,13 +123,13 @@ abstract class Operator implements OperatorInterface * * @return static */ - public function newInstance() + public function newInstance(): self { return new static($this->client, $this->api); } /** - * @return \GuzzleHttp\Psr7\Uri + * @return \GuzzleHttp\Psr7\Uri:null */ protected function getHttpBaseUrl() { diff --git a/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php b/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php index 43c6ce2..168518b 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php @@ -1,8 +1,11 @@ -name, 'metadata') !== false) { + if ($this->name && stripos($this->name, 'metadata') !== false) { $this->properties = new Parameter($data['properties']); } else { foreach ($data['properties'] as $name => $property) { @@ -166,7 +166,7 @@ class Parameter * * @return string */ - public function getName() + public function getName(): string { return $this->sentAs ?: $this->name; } @@ -176,7 +176,7 @@ class Parameter * * @return bool */ - public function isRequired() + public function isRequired(): bool { return $this->required === true; } @@ -189,7 +189,7 @@ class Parameter * @return bool TRUE if the validation passes * @throws \Exception If validation fails */ - public function validate($userValues) + public function validate($userValues): bool { $this->validateEnums($userValues); $this->validateType($userValues); @@ -245,9 +245,9 @@ class Parameter * @returns Parameter * @throws \Exception */ - private function getNestedProperty($key) + private function getNestedProperty($key): Parameter { - if (stripos($this->name, 'metadata') !== false && $this->properties instanceof Parameter) { + if ($this->name && stripos($this->name, 'metadata') !== false && $this->properties instanceof Parameter) { return $this->properties; } elseif (isset($this->properties[$key])) { return $this->properties[$key]; @@ -264,7 +264,7 @@ class Parameter * * @return bool */ - private function hasCorrectType($userValue) + private function hasCorrectType($userValue): bool { // Helper fn to see whether an array is associative (i.e. a JSON object) $isAssociative = function ($value) { @@ -293,7 +293,7 @@ class Parameter * * @return bool */ - public function isArray() + public function isArray(): bool { return $this->type == 'array' && $this->itemSchema instanceof Parameter; } @@ -303,12 +303,12 @@ class Parameter * * @return bool */ - public function isObject() + public function isObject(): bool { return $this->type == 'object' && !empty($this->properties); } - public function getLocation() + public function getLocation(): string { return $this->location; } @@ -320,7 +320,7 @@ class Parameter * * @return bool */ - public function hasLocation($value) + public function hasLocation($value): bool { return $this->location == $value; } @@ -330,7 +330,7 @@ class Parameter * * @return string|null */ - public function getPath() + public function getPath(): string { return $this->path; } @@ -338,7 +338,7 @@ class Parameter /** * Retrieves the common schema that an array parameter applies to all its child elements. * - * @return Parameter + * @return Parameter|null */ public function getItemSchema() { @@ -350,7 +350,7 @@ class Parameter * * @param string $name */ - public function setName($name) + public function setName(string $name) { $this->name = $name; } @@ -362,7 +362,7 @@ class Parameter * * @return null|Parameter */ - public function getProperty($name) + public function getProperty(string $name) { if ($this->properties instanceof Parameter) { $this->properties->setName($name); @@ -377,12 +377,12 @@ class Parameter * * @return string|null */ - public function getPrefix() + public function getPrefix(): string { return $this->prefix; } - public function getPrefixedName() + public function getPrefixedName(): string { return $this->prefix . $this->getName(); } diff --git a/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php b/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php index 72bcfce..a9e3aba 100644 --- a/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php +++ b/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php @@ -1,4 +1,4 @@ -internalState[$offset]); } @@ -48,7 +48,7 @@ trait ArrayAccessTrait * * @param string $offset */ - public function offsetUnset($offset) + public function offsetUnset(string $offset) { unset($this->internalState[$offset]); } @@ -60,7 +60,7 @@ trait ArrayAccessTrait * * @return mixed|null */ - public function offsetGet($offset) + public function offsetGet(string $offset) { return $this->offsetExists($offset) ? $this->internalState[$offset] : null; } diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php b/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php index 1a36cc0..61a07c9 100644 --- a/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php +++ b/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php @@ -1,4 +1,4 @@ -getUri(), 'tokens') !== false && $request->getMethod() == 'POST'; } diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php b/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php index b4ab381..22ebc09 100644 --- a/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php +++ b/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php @@ -1,4 +1,4 @@ -response = $response; } - public function getRequest() + public function getRequest(): RequestInterface { return $this->request; } - public function getResponse() + public function getResponse(): ResponseInterface { return $this->response; } diff --git a/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php b/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php index a7cb26e..1776890 100644 --- a/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php +++ b/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php @@ -1,4 +1,4 @@ -docDomain . $link; @@ -78,7 +78,7 @@ class Builder * @codeCoverageIgnore * @return string */ - public function str(MessageInterface $message) + public function str(MessageInterface $message): string { if ($message instanceof RequestInterface) { $msg = trim($message->getMethod() . ' ' @@ -112,7 +112,7 @@ class Builder * * @return BadResponseError */ - public function httpError(RequestInterface $request, ResponseInterface $response) + public function httpError(RequestInterface $request, ResponseInterface $response): BadResponseError { $message = $this->header('HTTP Error'); @@ -138,7 +138,7 @@ class Builder return $e; } - private function getStatusCodeMessage($statusCode) + private function getStatusCodeMessage(int $statusCode): string { $errors = [ 400 => 'Please ensure that your input values are valid and well-formed. ', @@ -159,7 +159,7 @@ class Builder * * @return UserInputError */ - public function userInputError($expectedType, $userValue, $furtherLink = null) + public function userInputError(string $expectedType, $userValue, string $furtherLink = null): UserInputError { $message = $this->header('User Input Error'); diff --git a/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php b/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php index 3e01d74..db18f62 100644 --- a/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php +++ b/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php @@ -1,4 +1,4 @@ -jsonStructure = $this->setPath($path, $value, $this->jsonStructure); } @@ -53,9 +53,10 @@ class JsonPath * @param $path * @param $value * @param $json + * * @return mixed */ - private function setPath($path, $value, $json) + private function setPath(string $path, $value, array $json): array { $nodes = explode('.', $path); $point = array_shift($nodes); @@ -87,9 +88,10 @@ class JsonPath * Get a path's value. If no path can be matched, NULL is returned. * * @param $path + * * @return mixed|null */ - public function get($path) + public function get(string $path) { return $this->getPath($path, $this->jsonStructure); } @@ -99,9 +101,10 @@ class JsonPath * * @param $path * @param $json + * * @return null */ - private function getPath($path, $json) + private function getPath(string $path, $json) { $nodes = explode('.', $path); $point = array_shift($nodes); diff --git a/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php b/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php index 2c12ec0..74d2a78 100644 --- a/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php +++ b/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php @@ -1,4 +1,4 @@ -makeDiff($src, $dest); } - public function makeDiff($srcStruct, $desStruct, $path = '') + public function makeDiff($srcStruct, $desStruct, string $path = ''): array { $changes = []; @@ -28,7 +28,7 @@ class JsonPatch return $changes; } - protected function handleArray($srcStruct, $desStruct, $path) + protected function handleArray(array $srcStruct, array $desStruct, string $path): array { $changes = []; @@ -53,7 +53,7 @@ class JsonPatch return $changes; } - protected function handleObject($srcStruct, $desStruct, $path) + protected function handleObject(\stdClass $srcStruct, \stdClass $desStruct, string $path): array { $changes = []; @@ -76,12 +76,12 @@ class JsonPatch return $changes; } - protected function shouldPartiallyReplace($o1, $o2) + protected function shouldPartiallyReplace(\stdClass $o1, \stdClass $o2): bool { return count(array_diff_key((array) $o1, (array) $o2)) < count($o1); } - protected function arrayDiff(array $a1, array $a2) + protected function arrayDiff(array $a1, array $a2): array { $result = []; @@ -94,8 +94,10 @@ class JsonPatch return $result; } - protected function path($root, $path) + protected function path(string $root, $path): string { + $path = (string) $path; + if ($path === '_empty_') { $path = ''; } @@ -103,7 +105,7 @@ class JsonPatch return rtrim($root, '/') . '/' . ltrim($path, '/'); } - protected function makePatch($op, $path, $val = null) + protected function makePatch(string $op, string $path, $val = null): array { switch ($op) { default: diff --git a/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php b/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php index a1cd380..e1e3f65 100644 --- a/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php +++ b/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php @@ -1,4 +1,4 @@ -validator = $validator ?: new Validator(); } - public function getPropertyPaths() + public function getPropertyPaths(): array { $paths = []; @@ -26,7 +29,7 @@ class Schema return $paths; } - public function normalizeObject($subject, array $aliases) + public function normalizeObject($subject, array $aliases): \stdClass { $out = new \stdClass; @@ -49,17 +52,17 @@ class Schema $this->validator->check($data, $this->body); } - public function isValid() + public function isValid(): bool { return $this->validator->isValid(); } - public function getErrors() + public function getErrors(): array { return $this->validator->getErrors(); } - public function getErrorString() + public function getErrorString(): string { $msg = "Provided values do not validate. Errors:\n"; diff --git a/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php b/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php index 9f79b07..989fde7 100644 --- a/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php +++ b/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php @@ -1,4 +1,4 @@ -getHeaderLine('Content-Type'), 'application/json') === 0) { $json = Utils::jsonDecode($response); @@ -79,12 +79,12 @@ abstract class AbstractResource extends Operator implements ResourceInterface * * @return mixed|void */ - public function populateFromArray(array $array) + public function populateFromArray(array $array): self { $reflClass = new \ReflectionClass($this); foreach ($array as $key => $val) { - $propertyName = isset($this->aliases[$key]) ? $this->aliases[$key] : $key; + $propertyName = (string) (isset($this->aliases[$key]) ? $this->aliases[$key] : $key); if (property_exists($this, $propertyName)) { if ($type = $this->extractTypeFromDocBlock($reflClass, $propertyName)) { @@ -94,9 +94,11 @@ abstract class AbstractResource extends Operator implements ResourceInterface $this->$propertyName = $val; } } + + return $this; } - private function parseDocBlockValue($type, $val) + private function parseDocBlockValue(string $type, $val) { if (strpos($type, '[]') === 0 && is_array($val)) { $array = []; @@ -113,7 +115,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $val; } - private function isNotNativeType($type) + private function isNotNativeType(string $type): bool { return !in_array($type, [ 'string', 'bool', 'boolean', 'double', 'null', 'array', 'object', 'int', 'integer', 'float', 'numeric', @@ -121,7 +123,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface ]); } - private function normalizeModelClass($class) + private function normalizeModelClass(string $class): string { if (strpos($class, '\\') === false) { $currentNamespace = (new \ReflectionClass($this))->getNamespaceName(); @@ -131,7 +133,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $class; } - private function extractTypeFromDocBlock(\ReflectionClass $reflClass, $propertyName) + private function extractTypeFromDocBlock(\ReflectionClass $reflClass, string $propertyName) { $docComment = $reflClass->getProperty($propertyName)->getDocComment(); @@ -174,7 +176,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $this->execute($definition, $this->getAttrs(array_keys($definition['params']))); } - private function getResourcesKey() + private function getResourcesKey(): string { $resourcesKey = $this->resourcesKey; @@ -189,7 +191,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface /** * {@inheritDoc} */ - public function enumerate(array $def, array $userVals = [], callable $mapFn = null) + public function enumerate(array $def, array $userVals = [], callable $mapFn = null): \Generator { $operation = $this->getOperation($def); @@ -217,7 +219,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $iterator(); } - public function extractMultipleInstances(ResponseInterface $response, $key = null) + public function extractMultipleInstances(ResponseInterface $response, string $key = null): array { $key = $key ?: $this->getResourcesKey(); $resourcesData = Utils::jsonDecode($response)[$key]; diff --git a/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php b/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php index 19579c1..5f16bfa 100644 --- a/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php +++ b/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php @@ -1,4 +1,4 @@ -waitUntil('ACTIVE', $timeout); } - public function waitUntilDeleted($timeout = 60, $sleepPeriod = 1) + public function waitUntilDeleted($timeout = 60, int $sleepPeriod = 1) { $startTime = time(); diff --git a/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php b/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php index 63d4455..05507f0 100644 --- a/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php +++ b/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php @@ -1,4 +1,4 @@ -rootNamespace, $serviceName, $serviceVersion); @@ -70,19 +70,18 @@ class Builder * directly - this setup includes the configuration of the HTTP client's base URL, and the * attachment of an authentication handler. * - * @param $serviceName The name of the service as it appears in the OpenCloud\* namespace - * @param $serviceVersion The major version of the service - * @param array $serviceOptions The service-specific options to use + * @param string $serviceName The name of the service as it appears in the OpenCloud\* namespace + * @param int $serviceVersion The major version of the service + * @param array $serviceOptions The service-specific options to use * * @return \OpenCloud\Common\Service\ServiceInterface * * @throws \Exception */ - public function createService($serviceName, $serviceVersion, array $serviceOptions = []) + public function createService(string $serviceName, int $serviceVersion, array $serviceOptions = []): ServiceInterface { $options = $this->mergeOptions($serviceOptions); - $this->stockIdentityService($options); $this->stockAuthHandler($options); $this->stockHttpClient($options, $serviceName); @@ -91,7 +90,7 @@ class Builder return new $serviceClass($options['httpClient'], new $apiClass()); } - private function stockHttpClient(array &$options, $serviceName) + private function stockHttpClient(array &$options, string $serviceName) { if (!isset($options['httpClient']) || !($options['httpClient'] instanceof ClientInterface)) { if (strcasecmp($serviceName, 'identity') === 0) { @@ -121,16 +120,9 @@ class Builder } } - private function stockIdentityService(array &$options) - { - if (!isset($options['identityService'])) { - $httpClient = $this->httpClient($options['authUrl'], HandlerStack::create()); - $options['identityService'] = Service::factory($httpClient); - } - } - /** * @param array $options + * * @codeCoverageIgnore */ private function stockAuthHandler(array &$options) @@ -142,14 +134,14 @@ class Builder } } - private function getStack(callable $authHandler, Token $token = null) + private function getStack(callable $authHandler, Token $token = null): HandlerStack { $stack = HandlerStack::create(); $stack->push(Middleware::authHandler($authHandler, $token)); return $stack; } - private function httpClient($baseUrl, HandlerStack $stack) + private function httpClient(string $baseUrl, HandlerStack $stack): ClientInterface { return new Client([ 'base_uri' => Utils::normalizeUrl($baseUrl), @@ -157,7 +149,7 @@ class Builder ]); } - private function mergeOptions(array $serviceOptions) + private function mergeOptions(array $serviceOptions): array { $options = array_merge($this->defaults, $this->globalOptions, $serviceOptions); @@ -165,6 +157,12 @@ class Builder throw new \InvalidArgumentException('"authUrl" is a required option'); } + if (!isset($options['identityService']) || !($options['identityService'] instanceof IdentityService)) { + throw new \InvalidArgumentException(sprintf( + '"identityService" must be specified and implement %s', IdentityService::class + )); + } + return $options; } -} +} \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php b/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php index 6ad3089..0f2f23c 100644 --- a/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php +++ b/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php @@ -1,4 +1,4 @@ -getName(); if ($path = $param->getPath()) { @@ -46,7 +46,7 @@ class JsonSerializer * * @return array|mixed */ - private function stockArrayJson(Parameter $param, $userValue) + private function stockArrayJson(Parameter $param, array $userValue): array { $elems = []; foreach ($userValue as $item) { @@ -63,7 +63,7 @@ class JsonSerializer * * @return array */ - private function stockObjectJson(Parameter $param, $userValue) + private function stockObjectJson(Parameter $param, \stdClass $userValue): array { $object = []; foreach ($userValue as $key => $val) { @@ -82,12 +82,12 @@ class JsonSerializer * * @return array */ - public function stockJson(Parameter $param, $userValue, $json) + public function stockJson(Parameter $param, $userValue, array $json): array { if ($param->isArray()) { $userValue = $this->stockArrayJson($param, $userValue); } elseif ($param->isObject()) { - $userValue = $this->stockObjectJson($param, $userValue); + $userValue = $this->stockObjectJson($param, (object) $userValue); } // Populate the final value return $this->stockValue($param, $userValue, $json); diff --git a/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php b/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php index 916ff22..2b407a4 100644 --- a/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php +++ b/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php @@ -1,4 +1,4 @@ -jsonSerializer = $jsonSerializer ?: new JsonSerializer(); } - public function serializeOptions(Operation $operation, array $userValues = []) + public function serializeOptions(Operation $operation, array $userValues = []): array { $options = ['headers' => []]; diff --git a/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php b/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php index c2a2dc1..ffac9ce 100644 --- a/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php +++ b/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php @@ -1,4 +1,4 @@ - 'JSON_ERROR_DEPTH - Maximum stack depth exceeded', @@ -40,11 +40,11 @@ class Utils * Method for flattening a nested array. * * @param array $data The nested array - * @param null $key The key to extract + * @param string $key The key to extract * * @return array */ - public static function flattenJson($data, $key = null) + public static function flattenJson($data, string $key = null) { return (!empty($data) && $key && isset($data[$key])) ? $data[$key] : $data; } @@ -59,7 +59,7 @@ class Utils * * @return string */ - public static function normalizeUrl($url) + public static function normalizeUrl(string $url): string { if (strpos($url, 'http') === false) { $url = 'http://' . $url; @@ -76,12 +76,12 @@ class Utils * * @return UriInterface */ - public static function addPaths(UriInterface $uri, ...$paths) + public static function addPaths(UriInterface $uri, ...$paths): UriInterface { return uri_for(rtrim((string) $uri, '/') . '/' . implode('/', $paths)); } - public static function appendPath(UriInterface $uri, $path) + public static function appendPath(UriInterface $uri, $path): UriInterface { return uri_for(rtrim((string) $uri, '/') . '/' . $path); } -- cgit v1.2.3