From 54ec6723deb44e325782afd366eeec01ee29ac55 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 23 Mar 2016 15:30:47 +0100 Subject: Maj Library --- .../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 +- 10 files changed, 31 insertions(+), 29 deletions(-) (limited to 'server/vendor/php-opencloud/common/src/Common/Resource') 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 @@ -