diff --git a/src/Annotation/RestAnnotationInterface.php b/src/Annotation/RestAnnotationInterface.php index 0a08380..89d4f87 100644 --- a/src/Annotation/RestAnnotationInterface.php +++ b/src/Annotation/RestAnnotationInterface.php @@ -11,5 +11,5 @@ interface RestAnnotationInterface { public function isSeveralSupported(): bool; - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void; + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod); } diff --git a/src/Attribute/Body.php b/src/Attribute/Body.php index ed8ec65..263e237 100644 --- a/src/Attribute/Body.php +++ b/src/Attribute/Body.php @@ -33,25 +33,33 @@ class Body implements RestAttributeInterface private $optional; public function __construct( - array $data = [], + array $options = [], string $parameterName = null, ?string $denormalizationType = null, ?string $denormalizationGroup = null, ?bool $optional = null ) { - $this->setParameterName($data['parameterName'] ?? $parameterName); - $this->setDenormalizationType($data['denormalizationType'] ?? $denormalizationType); - $this->setDenormalizationGroup($data['denormalizationGroup'] ?? $denormalizationGroup); - $this->setOptional($data['optional'] ?? $optional); + $this->setParameterName($options['parameterName'] ?? $parameterName); + $this->setDenormalizationType($options['denormalizationType'] ?? $denormalizationType); + $this->setDenormalizationGroup($options['denormalizationGroup'] ?? $denormalizationGroup); + $this->setOptional($options['optional'] ?? $optional); } - private function setDenormalizationType(?string $denormalizationType): self + /** + * @param string|null $denormalizationType + * @return $this + */ + private function setDenormalizationType($denormalizationType): self { $this->denormalizationType = $denormalizationType; return $this; } - public function setDenormalizationGroup(?string $denormalizationGroup): self + /** + * @param string|null $denormalizationGroup + * @return $this + */ + public function setDenormalizationGroup($denormalizationGroup): self { $this->denormalizationGroup = $denormalizationGroup; return $this; @@ -63,13 +71,17 @@ private function setParameterName(string $parameterName): self return $this; } - private function setOptional(?bool $optional): self + /** + * @param bool|null $optional + * @return $this + */ + private function setOptional($optional): self { $this->optional = $optional; return $this; } - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod) { $options->setBodyParameterName($this->parameterName); $options->setBodyDenormalizationType($this->resolveDenormalizationType($reflectionMethod)); diff --git a/src/Attribute/BodyContentType.php b/src/Attribute/BodyContentType.php index 4507be8..d1b0f1a 100644 --- a/src/Attribute/BodyContentType.php +++ b/src/Attribute/BodyContentType.php @@ -22,12 +22,12 @@ class BodyContentType implements RestAttributeInterface private $jsonEncodedBody; public function __construct( - array $data = [], + array $options = [], array $supportedContentTypes = null, bool $jsonEncodedBody = false ) { - $this->setSupportedContentTypes($data['supportedContentTypes'] ?? $supportedContentTypes); - $this->setJsonEncodedBody($data['jsonEncodedBody'] ?? $jsonEncodedBody); + $this->setSupportedContentTypes($options['supportedContentTypes'] ?? $supportedContentTypes); + $this->setJsonEncodedBody($options['jsonEncodedBody'] ?? $jsonEncodedBody); } private function setSupportedContentTypes(array $supportedContentTypes): self @@ -42,7 +42,7 @@ private function setJsonEncodedBody(bool $jsonEncodedBody): self return $this; } - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod) { $options->setSupportedContentTypes($this->supportedContentTypes, $this->jsonEncodedBody); } diff --git a/src/Attribute/PathAttribute.php b/src/Attribute/PathAttribute.php index 860570b..743d47d 100644 --- a/src/Attribute/PathAttribute.php +++ b/src/Attribute/PathAttribute.php @@ -34,16 +34,16 @@ class PathAttribute implements RestAttributeInterface private $resolutionMandatory; public function __construct( - array $data = [], + array $options = [], string $parameterName = null, string $pathPartName = null, ?string $resolverType = null, ?bool $resolutionMandatory = null ) { - $this->setParameterName($data['parameterName'] ?? $parameterName); - $this->setPathPartName($data['pathPartName'] ?? $pathPartName); - $this->setResolverType($data['resolverType'] ?? $resolverType); - $this->setResolutionMandatory($data['resolutionMandatory'] ?? $resolutionMandatory); + $this->setParameterName($options['parameterName'] ?? $parameterName); + $this->setPathPartName($options['pathPartName'] ?? $pathPartName); + $this->setResolverType($options['resolverType'] ?? $resolverType); + $this->setResolutionMandatory($options['resolutionMandatory'] ?? $resolutionMandatory); } private function setParameterName(string $parameterName): self @@ -58,19 +58,27 @@ private function setPathPartName(string $pathPartName): self return $this; } - private function setResolverType(?string $resolverType): self + /** + * @param string|null $resolverType + * @return $this + */ + private function setResolverType($resolverType): self { $this->resolverType = $resolverType; return $this; } - private function setResolutionMandatory(?bool $resolutionMandatory): self + /** + * @param bool|null $resolutionMandatory + * @return $this + */ + private function setResolutionMandatory($resolutionMandatory): self { $this->resolutionMandatory = $resolutionMandatory; return $this; } - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod) { $options->addPathAttributeResolverOptions( (new PathAttributeResolverOptions()) diff --git a/src/Attribute/Query.php b/src/Attribute/Query.php index 6ace7d0..72bd1a3 100644 --- a/src/Attribute/Query.php +++ b/src/Attribute/Query.php @@ -34,16 +34,16 @@ class Query implements RestAttributeInterface private $validation; public function __construct( - array $data = [], + array $options = [], string $parameterName = null, ?string $denormalizationType = null, ?string $denormalizationGroup = null, ?Validation $validation = null ) { - $this->setParameterName($data['parameterName'] ?? $parameterName); - $this->setDenormalizationType($data['denormalizationType'] ?? $denormalizationType); - $this->setDenormalizationGroup($data['denormalizationGroup'] ?? $denormalizationGroup); - $this->setValidation($data['validation'] ?? $validation); + $this->setParameterName($options['parameterName'] ?? $parameterName); + $this->setDenormalizationType($options['denormalizationType'] ?? $denormalizationType); + $this->setDenormalizationGroup($options['denormalizationGroup'] ?? $denormalizationGroup); + $this->setValidation($options['validation'] ?? $validation); } private function setParameterName(string $parameterName): self @@ -52,25 +52,37 @@ private function setParameterName(string $parameterName): self return $this; } - private function setDenormalizationType(?string $denormalizationType): self + /** + * @param string|null $denormalizationType + * @return $this + */ + private function setDenormalizationType($denormalizationType): self { $this->denormalizationType = $denormalizationType; return $this; } - public function setDenormalizationGroup(?string $denormalizationGroup): self + /** + * @param string|null $denormalizationGroup + * @return $this + */ + public function setDenormalizationGroup($denormalizationGroup): self { $this->denormalizationGroup = $denormalizationGroup; return $this; } - private function setValidation(?Validation $validation): self + /** + * @param Validation|null $validation + * @return $this + */ + private function setValidation($validation): self { $this->validation = $validation; return $this; } - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod) { $resolverOptions = (new QueryResolverOptions()) ->setParameterName($this->parameterName) @@ -104,7 +116,7 @@ private function resolveDenormalizationType(ReflectionMethodWrapper $reflectionM return $typeName; } - private function setValidationOptions(ReflectionMethodWrapper $reflectionMethod, QueryResolverOptions $options) + private function setValidationOptions(ReflectionMethodWrapper $reflectionMethod, QueryResolverOptions $options): void { if ($this->validation === null) { return; diff --git a/src/Attribute/RequiredPermissions.php b/src/Attribute/RequiredPermissions.php index 0880414..648d0c1 100644 --- a/src/Attribute/RequiredPermissions.php +++ b/src/Attribute/RequiredPermissions.php @@ -17,10 +17,10 @@ class RequiredPermissions implements RestAttributeInterface private $permissions; public function __construct( - array $data = [], + array $options = [], array $permissions = null ) { - $this->setPermissions($data['permissions'] ?? $permissions); + $this->setPermissions($options['permissions'] ?? $permissions); } private function setPermissions(array $permissions): self @@ -29,7 +29,7 @@ private function setPermissions(array $permissions): self return $this; } - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod) { $options->setRequiredPermissions( array_unique(array_merge($options->getRequiredPermissions(), $this->permissions)) diff --git a/src/Attribute/ResponseNormalization.php b/src/Attribute/ResponseNormalization.php index 22c1993..d5a4883 100644 --- a/src/Attribute/ResponseNormalization.php +++ b/src/Attribute/ResponseNormalization.php @@ -22,28 +22,36 @@ class ResponseNormalization implements RestAttributeInterface private $normalizationGroup; public function __construct( - array $data = [], + array $options = [], ?string $normalizationType = null, ?string $normalizationGroup = null ) { - $this->setNormalizationType($data['normalizationType'] ?? $normalizationType); - $this->setNormalizationGroup($data['normalizationGroup'] ?? $normalizationGroup); + $this->setNormalizationType($options['normalizationType'] ?? $normalizationType); + $this->setNormalizationGroup($options['normalizationGroup'] ?? $normalizationGroup); } - private function setNormalizationType(?string $normalizationType): self + /** + * @param string|null $normalizationType + * @return $this + */ + private function setNormalizationType($normalizationType): self { $this->normalizationType = $normalizationType; return $this; } - public function setNormalizationGroup(?string $normalizationGroup): self + /** + * @param string|null $normalizationGroup + * @return $this + */ + public function setNormalizationGroup($normalizationGroup): self { $this->normalizationGroup = $normalizationGroup; return $this; } - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod) { $options->setResponseNormalizationType($this->normalizationType); $options->setResponseNormalizationGroup($this->normalizationGroup); diff --git a/src/Attribute/RestAttributeInterface.php b/src/Attribute/RestAttributeInterface.php index 957fd3d..92f3d8d 100644 --- a/src/Attribute/RestAttributeInterface.php +++ b/src/Attribute/RestAttributeInterface.php @@ -9,5 +9,5 @@ interface RestAttributeInterface { - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void; + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod); } diff --git a/src/Attribute/Validation.php b/src/Attribute/Validation.php index a336355..8b9dc39 100644 --- a/src/Attribute/Validation.php +++ b/src/Attribute/Validation.php @@ -29,14 +29,14 @@ class Validation implements RestAttributeInterface private $enabled; public function __construct( - array $data = [], + array $options = [], array $groups = [Constraint::DEFAULT_GROUP], array $violationPathMap = [], bool $enabled = true ) { - $this->setGroups($data['groups'] ?? $groups); - $this->setViolationPathMap($data['violationPathMap'] ?? $violationPathMap); - $this->setEnabled($data['enabled'] ?? $enabled); + $this->setGroups($options['groups'] ?? $groups); + $this->setViolationPathMap($options['violationPathMap'] ?? $violationPathMap); + $this->setEnabled($options['enabled'] ?? $enabled); } private function setGroups(array $groups): self @@ -57,7 +57,7 @@ private function setEnabled(bool $enabled): self return $this; } - public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod): void + public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod) { if (!$this->enabled) { $options->disableBodyValidation(); diff --git a/src/Service/RoutingLoader/RestRequestAnnotationOptionsBuilder.php b/src/Service/RoutingLoader/RestRequestAnnotationOptionsBuilder.php index a7c14af..3e5d241 100644 --- a/src/Service/RoutingLoader/RestRequestAnnotationOptionsBuilder.php +++ b/src/Service/RoutingLoader/RestRequestAnnotationOptionsBuilder.php @@ -12,7 +12,7 @@ /** * @internal */ -class RestRequestAnnotationOptionsBuilder implements RestRequestOptionsBuilderInterface +class RestRequestAnnotationOptionsBuilder { /** * @var RestRequestOptionsValidator diff --git a/src/Service/RoutingLoader/RestRequestAttributeOptionsBuilder.php b/src/Service/RoutingLoader/RestRequestAttributeOptionsBuilder.php index e5c9f46..4275ff3 100644 --- a/src/Service/RoutingLoader/RestRequestAttributeOptionsBuilder.php +++ b/src/Service/RoutingLoader/RestRequestAttributeOptionsBuilder.php @@ -12,7 +12,7 @@ /** * @internal */ -class RestRequestAttributeOptionsBuilder implements RestRequestOptionsBuilderInterface +class RestRequestAttributeOptionsBuilder { /** * @var RestRequestOptionsValidator diff --git a/src/Service/RoutingLoader/RestRequestOptionsBuilderInterface.php b/src/Service/RoutingLoader/RestRequestOptionsBuilderInterface.php deleted file mode 100644 index bee12cd..0000000 --- a/src/Service/RoutingLoader/RestRequestOptionsBuilderInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -