From ab4dd8a8ad2044abeb6cda0130a73db7faa0086d Mon Sep 17 00:00:00 2001 From: Mykhailo Shtanko Date: Tue, 26 Dec 2023 03:53:00 +0200 Subject: [PATCH] [RequestMapper] Update Dependencies, update functional library with breaking changes --- .php-cs-fixer.dist.php | 59 ++++++++++++++++--- Attribute/ArrayType.php | 14 ++++- Attribute/RequestBody.php | 17 +++++- ClassMapper/ClassMapper.php | 17 ++++-- ClassMapper/ClassMapperInterface.php | 11 ++++ Data/ErrorContract.php | 11 ++++ Data/ErrorInterface.php | 11 ++++ Data/FormattedError.php | 20 +++++-- Data/HasHeaders.php | 11 ++++ Data/TypeError.php | 14 ++++- Data/ValidationError.php | 14 ++++- Event/ListenerExceptionEvent.php | 14 ++++- EventListener/ExceptionListener.php | 14 ++++- EventListener/JsonRequestListener.php | 14 ++++- EventListener/MergeRequestListener.php | 11 ++++ EventListener/RequestMapperListener.php | 18 ++++-- Exception/ClassExtractorException.php | 14 ++++- Exception/ConstraintException.php | 11 ++++ Exception/ConverterException.php | 11 ++++ Exception/ErrorInvalidArgumentException.php | 11 ++++ Exception/ExceptionMapperException.php | 11 ++++ Exception/ExceptionMapperLocatorException.php | 11 ++++ Exception/HelperException.php | 11 ++++ Exception/InvalidPropertyTypeException.php | 11 ++++ Exception/PropertyMapperLocatorException.php | 11 ++++ .../TypeErrorInvalidArgumentException.php | 16 ++++- Exception/TypeExtractorLocatorException.php | 16 ++++- Exception/ValidationException.php | 12 +++- ExceptionFormatter/ExceptionFormatter.php | 14 ++++- .../ExceptionFormatterInterface.php | 11 ++++ .../ExceptionFormatterLocator.php | 15 ++++- .../ExceptionFormatterLocatorInterface.php | 13 +++- .../Formatter/FormatterInterface.php | 11 ++++ .../Formatter/HttpExceptionFormatter.php | 11 ++++ .../Formatter/ThrowableFormatter.php | 11 ++++ .../Formatter/ValidationFormatter.php | 14 ++++- ExceptionMapper/ExceptionMapperLocator.php | 13 +++- .../ExceptionMapperLocatorInterface.php | 11 ++++ .../Mapper/ExceptionMapperInterface.php | 11 ++++ ...ingConstructorArgumentsExceptionMapper.php | 14 ++++- .../Mapper/TypeErrorExceptionMapper.php | 11 ++++ Extractor/ConstraintExtractor.php | 18 +++++- Extractor/DiscriminatorMapExtractor.php | 11 ++++ Extractor/ParametersExtractor.php | 14 ++++- Helper/AttributeHelper.php | 23 +++++--- Helper/ClassHelper.php | 32 ++++++---- Helper/ConstraintsHelper.php | 15 ++++- Helper/Header.php | 11 ++++ Helper/HeaderHelper.php | 21 ++++--- Helper/PropertyHelper.php | 19 ++++-- Helper/RequestBodyHelper.php | 18 ++++-- Helper/SerializerHelper.php | 17 ++++-- Helper/StringHelper.php | 15 ++++- .../Mapper/ArrayAsAttributePropertyMapper.php | 14 ++++- .../Mapper/BuiltinPropertyMapper.php | 14 ++++- .../Mapper/DefaultPropertyMapper.php | 11 ++++ .../Mapper/DocBlockArrayPropertyMapper.php | 14 ++++- .../Mapper/PropertyMapperInterface.php | 11 ++++ PropertyMapper/PropertyMapperLocator.php | 16 ++++- .../PropertyMapperLocatorInterface.php | 11 ++++ RequestMapper/RequestMapper.php | 19 +++++- RequestMapper/RequestMapperInterface.php | 11 ++++ RequestMapperBundle.php | 11 ++++ RequestMapperExtension.php | 11 ++++ Resources/bundles.php | 10 ++++ .../EventListener/JsonRequestListenerTest.php | 11 ++++ .../RequestMapperListenerTest.php | 13 +++- .../ExceptionFormatterTest.php | 11 ++++ .../Extractor/ConstraintExtractorTest.php | 11 ++++ .../Locator/ExceptionFormatterLocatorTest.php | 11 ++++ .../Func/RequestMapper/RequestMapperTest.php | 11 ++++ Tests/Helper/RequestHelper.php | 11 ++++ Tests/Helper/TestConstant.php | 11 ++++ .../Controller/TestCallableController.php | 11 ++++ ...rameterNameAndParameterClassController.php | 11 ++++ ...CallableWithoutParameterNameController.php | 11 ++++ Tests/Stub/Controller/TestController.php | 11 ++++ ...rameterNameAndParameterClassController.php | 11 ++++ .../TestWithoutParameterNameController.php | 11 ++++ Tests/Stub/Enum/TestEnum.php | 11 ++++ Tests/Stub/Kernel.php | 11 ++++ .../Request/CreateCardSettingsRequest.php | 11 ++++ .../Stub/Request/CreateNestedUserRequest.php | 11 ++++ Tests/Stub/Request/CreateSettingsRequest.php | 14 ++++- Tests/Stub/Request/CreateUserRequest.php | 11 ++++ .../Request/CreateUserRequestWithEnum.php | 11 ++++ .../Request/CreateUserSettingsRequest.php | 11 ++++ .../CreateUserWithSerializedNameRequest.php | 11 ++++ Tests/Stub/Request/TestRequest.php | 14 ++++- Tests/Stub/Request/TestWithHeadersRequest.php | 14 ++++- .../Request/TestWithoutParametersRequest.php | 11 ++++ .../Attribute/RequestBodyAttributeTest.php | 11 ++++ Tests/Unit/Data/TypeErrorTest.php | 11 ++++ Tests/Unit/Data/ValidationErrorTest.php | 11 ++++ .../Unit/Event/ListenerExceptionEventTest.php | 11 ++++ .../EventListener/ExceptionListenerTest.php | 11 ++++ .../MergeRequestListenerTest.php | 11 ++++ .../RequestMapperListenerTest.php | 13 +++- .../Mapper/TypeErrorExceptionMapperTest.php | 11 ++++ .../DiscriminatorMapExtractorTest.php | 11 ++++ .../Extractor/ParametersExtractorTest.php | 11 ++++ Tests/Unit/Helper/ClassHelperTest.php | 11 ++++ Tests/Unit/Helper/ConstraintHelperTest.php | 11 ++++ Tests/Unit/Helper/SerializerHelperTest.php | 11 ++++ Tests/Unit/Helper/StringHelperTest.php | 11 ++++ .../Unit/RequestMapper/RequestMapperTest.php | 11 ++++ Tests/Unit/Resources/BundlesTest.php | 11 ++++ .../Extractor/ArrayTypeAttributeExtractor.php | 11 ++++ .../Extractor/DocBlockTypeExtractor.php | 14 ++++- .../Extractor/TypeExtractorInterface.php | 15 ++++- TypeExtractor/TypeExtractorLocator.php | 20 +++++-- .../TypeExtractorLocatorInterface.php | 15 ++++- composer.json | 26 ++++---- 113 files changed, 1375 insertions(+), 144 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f6a5540..cc8a48a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,13 +1,41 @@ exclude('var') ->exclude('vendor') ->exclude('Documentation') - ->notPath('#Enum#') - ->in(__DIR__) + ->ignoreDotFiles(true) + ->in($projectDirectory) ; $rules = [ @@ -18,15 +46,30 @@ '@PhpCsFixer' => true, '@PHP80Migration' => true, '@PHP80Migration:risky' => true, - '@PHPUnit84Migration:risky' => true, - 'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'], - 'comment_to_phpdoc' => ['ignored_tags' => ['scrutinizer']], - 'phpdoc_to_comment' => ['ignored_tags' => ['scrutinizer']], + '@PHP81Migration' => true, + '@PHP82Migration' => true, + '@PHP83Migration' => true, + '@PHPUnit100Migration:risky' => true, 'date_time_immutable' => true, - 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], + 'single_line_throw' => true, + 'php_unit_internal_class' => false, + 'phpdoc_align' => ['align' => 'left'], 'php_unit_test_case_static_method_calls' => false, 'php_unit_test_class_requires_covers' => false, - 'php_unit_internal_class' => false, + 'comment_to_phpdoc' => ['ignored_tags' => ['scrutinizer']], + 'phpdoc_to_comment' => ['ignored_tags' => ['scrutinizer']], + 'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'], + 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], + 'header_comment' => [ + 'comment_type' => 'PHPDoc', + 'header' => str_replace( + ['{{YEAR}}', '{{OWNER}}', '{{EMAIL}}'], + [$year, $owner, $email], + $header, + ), + 'location' => 'after_declare_strict', + 'separate' => 'top', + ], ]; return (new PhpCsFixer\Config()) diff --git a/Attribute/ArrayType.php b/Attribute/ArrayType.php index 9fb8d0c..7a5c7de 100644 --- a/Attribute/ArrayType.php +++ b/Attribute/ArrayType.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Attribute; #[\Attribute(\Attribute::TARGET_PROPERTY)] @@ -9,6 +20,5 @@ final class ArrayType { public function __construct( public readonly string $typeName, - ) { - } + ) {} } diff --git a/Attribute/RequestBody.php b/Attribute/RequestBody.php index e2f4a52..b0252aa 100644 --- a/Attribute/RequestBody.php +++ b/Attribute/RequestBody.php @@ -2,11 +2,23 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Attribute; use FRZB\Component\RequestMapper\Helper\PropertyHelper; use JetBrains\PhpStorm\Immutable; use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; /** @final */ #[Immutable] @@ -14,7 +26,10 @@ class RequestBody { public const DEFAULT_VALIDATION_GROUPS = ['Default']; - public const DEFAULT_SERIALIZER_CONTEXT = [AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT => true]; + public const DEFAULT_SERIALIZER_CONTEXT = [ + AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT => true, + DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true, + ]; public readonly array $validationGroups; public readonly array $serializerContext; diff --git a/ClassMapper/ClassMapper.php b/ClassMapper/ClassMapper.php index 243a080..42aa45a 100644 --- a/ClassMapper/ClassMapper.php +++ b/ClassMapper/ClassMapper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ClassMapper; use Fp\Collections\ArrayList; @@ -13,16 +24,14 @@ final class ClassMapper implements ClassMapperInterface { public function __construct( private readonly PropertyMapperLocator $mapperLocator, - ) { - } + ) {} public function map(string $className, mixed $value): array { try { return ArrayList::collect((new \ReflectionClass($className))->getProperties()) ->map(fn (\ReflectionProperty $property) => $this->mapperLocator->get($property)->map($property, $value) ?? []) - ->reduce(array_merge(...)) - ->getOrElse([]) + ->toMergedArray() ; } catch (\ReflectionException) { return []; diff --git a/ClassMapper/ClassMapperInterface.php b/ClassMapper/ClassMapperInterface.php index eb7442d..d1a885d 100644 --- a/ClassMapper/ClassMapperInterface.php +++ b/ClassMapper/ClassMapperInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ClassMapper; use FRZB\Component\DependencyInjection\Attribute\AsAlias; diff --git a/Data/ErrorContract.php b/Data/ErrorContract.php index e5e5dd4..024458f 100644 --- a/Data/ErrorContract.php +++ b/Data/ErrorContract.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Data; interface ErrorContract extends \Stringable, \JsonSerializable diff --git a/Data/ErrorInterface.php b/Data/ErrorInterface.php index 2bcdce0..34448a0 100644 --- a/Data/ErrorInterface.php +++ b/Data/ErrorInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Data; use Symfony\Component\Validator\ConstraintViolationInterface as ConstraintViolation; diff --git a/Data/FormattedError.php b/Data/FormattedError.php index 046612a..2e0bda8 100644 --- a/Data/FormattedError.php +++ b/Data/FormattedError.php @@ -2,9 +2,19 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Data; -use Fp\Collections\Entry; use Fp\Collections\HashMap; use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\Immutable; @@ -17,15 +27,13 @@ public function __construct( private readonly int $status, private readonly array $errors = [], private readonly array $trace = [], - ) { - } + ) {} public function __toString(): string { $errors = HashMap::collect($this->errors) - ->map(static fn (Entry $e) => sprintf('%s: [%s]', $e->key, $e->value)) - ->toAssocArray() - ->getOrElse([]) + ->mapKV(static fn (string $key, string $value) => [$key => sprintf('%s: [%s]', $key, $value)]) + ->toMergedArray() ; return sprintf('message: %s, status: %s, errors: %s', $this->message, $this->status, implode(', ', $errors)); diff --git a/Data/HasHeaders.php b/Data/HasHeaders.php index 4ad3c0c..9d6726a 100644 --- a/Data/HasHeaders.php +++ b/Data/HasHeaders.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Data; interface HasHeaders diff --git a/Data/TypeError.php b/Data/TypeError.php index c7a8215..97f1455 100644 --- a/Data/TypeError.php +++ b/Data/TypeError.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Data; use FRZB\Component\RequestMapper\Exception\TypeErrorInvalidArgumentException; @@ -17,8 +28,7 @@ public function __construct( public readonly int $position, public readonly string $expected, public readonly string $proposed, - ) { - } + ) {} public static function fromArray(array $params): self { diff --git a/Data/ValidationError.php b/Data/ValidationError.php index 2810ab7..84b984a 100644 --- a/Data/ValidationError.php +++ b/Data/ValidationError.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Data; use FRZB\Component\RequestMapper\Exception\ClassExtractorException; @@ -16,8 +27,7 @@ public function __construct( private readonly string $type, private readonly string $field, private readonly string $message, - ) { - } + ) {} public function __toString() { diff --git a/Event/ListenerExceptionEvent.php b/Event/ListenerExceptionEvent.php index dc2ced7..1c5a352 100644 --- a/Event/ListenerExceptionEvent.php +++ b/Event/ListenerExceptionEvent.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Event; use FRZB\Component\RequestMapper\Data\ErrorContract; @@ -14,8 +25,7 @@ public function __construct( private readonly \Throwable $exception, private readonly string $listenerClass, private readonly ?ErrorContract $errorContract = null, - ) { - } + ) {} public function getEvent(): Event { diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index 5a142ba..8c92ab0 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\EventListener; use FRZB\Component\RequestMapper\Event\ListenerExceptionEvent; @@ -20,8 +31,7 @@ class ExceptionListener public function __construct( private readonly ExceptionFormatter $exceptionFormatter, private readonly EventDispatcher $eventDispatcher, - ) { - } + ) {} public function onKernelException(ExceptionEvent $event): void { diff --git a/EventListener/JsonRequestListener.php b/EventListener/JsonRequestListener.php index 531ded0..2efd839 100644 --- a/EventListener/JsonRequestListener.php +++ b/EventListener/JsonRequestListener.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\EventListener; use FRZB\Component\RequestMapper\Event\ListenerExceptionEvent; @@ -35,8 +46,7 @@ class JsonRequestListener public function __construct( private readonly EventDispatcher $dispatcher, - ) { - } + ) {} public function onKernelRequest(RequestEvent $event): void { diff --git a/EventListener/MergeRequestListener.php b/EventListener/MergeRequestListener.php index 5abe535..09eab40 100644 --- a/EventListener/MergeRequestListener.php +++ b/EventListener/MergeRequestListener.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\EventListener; use Symfony\Component\EventDispatcher\Attribute\AsEventListener; diff --git a/EventListener/RequestMapperListener.php b/EventListener/RequestMapperListener.php index a34a3e4..0762a20 100644 --- a/EventListener/RequestMapperListener.php +++ b/EventListener/RequestMapperListener.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\EventListener; use FRZB\Component\RequestMapper\Attribute\RequestBody; @@ -18,8 +29,7 @@ class RequestMapperListener { public function __construct( private readonly RequestMapper $mapper, - ) { - } + ) {} /** @throws \Throwable */ public function onKernelController(ControllerEvent $event): void @@ -48,7 +58,7 @@ public function onKernelController(ControllerEvent $event): void } /** @throws \ReflectionException */ - private function getReflectionMethod(array|object|callable $controller): \ReflectionMethod|\ReflectionFunction + private function getReflectionMethod(array|callable|object $controller): \ReflectionFunction|\ReflectionMethod { return match (true) { \is_array($controller) => new \ReflectionMethod(...$controller), @@ -58,7 +68,7 @@ private function getReflectionMethod(array|object|callable $controller): \Reflec } /** @return array */ - private function getAttributes(\ReflectionMethod|\ReflectionFunction $method): array + private function getAttributes(\ReflectionFunction|\ReflectionMethod $method): array { return RequestBodyHelper::fromReflectionAttributes( ...$method->getAttributes(RequestBody::class, \ReflectionAttribute::IS_INSTANCEOF) diff --git a/Exception/ClassExtractorException.php b/Exception/ClassExtractorException.php index 1681d43..7e16c06 100644 --- a/Exception/ClassExtractorException.php +++ b/Exception/ClassExtractorException.php @@ -2,12 +2,22 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; use JetBrains\PhpStorm\Pure; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; -use Throwable; #[Immutable] final class ClassExtractorException extends \RuntimeException @@ -17,7 +27,7 @@ public function __construct( private readonly string $property, string $message, int $code = 0, - ?Throwable $previous = null + ?\Throwable $previous = null ) { parent::__construct($message, $code, $previous); } diff --git a/Exception/ConstraintException.php b/Exception/ConstraintException.php index ff788ff..54784ff 100644 --- a/Exception/ConstraintException.php +++ b/Exception/ConstraintException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/ConverterException.php b/Exception/ConverterException.php index 2cdcccd..a2451ba 100644 --- a/Exception/ConverterException.php +++ b/Exception/ConverterException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/ErrorInvalidArgumentException.php b/Exception/ErrorInvalidArgumentException.php index bfad016..a49da88 100644 --- a/Exception/ErrorInvalidArgumentException.php +++ b/Exception/ErrorInvalidArgumentException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/ExceptionMapperException.php b/Exception/ExceptionMapperException.php index 95f6863..f5433d6 100644 --- a/Exception/ExceptionMapperException.php +++ b/Exception/ExceptionMapperException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/ExceptionMapperLocatorException.php b/Exception/ExceptionMapperLocatorException.php index ae9ee7b..0b2cf85 100644 --- a/Exception/ExceptionMapperLocatorException.php +++ b/Exception/ExceptionMapperLocatorException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/HelperException.php b/Exception/HelperException.php index ea6a8b2..417842b 100644 --- a/Exception/HelperException.php +++ b/Exception/HelperException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/InvalidPropertyTypeException.php b/Exception/InvalidPropertyTypeException.php index 59e45ea..610b7de 100644 --- a/Exception/InvalidPropertyTypeException.php +++ b/Exception/InvalidPropertyTypeException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/PropertyMapperLocatorException.php b/Exception/PropertyMapperLocatorException.php index a0c387d..e8e536f 100644 --- a/Exception/PropertyMapperLocatorException.php +++ b/Exception/PropertyMapperLocatorException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; diff --git a/Exception/TypeErrorInvalidArgumentException.php b/Exception/TypeErrorInvalidArgumentException.php index 873583f..903fddb 100644 --- a/Exception/TypeErrorInvalidArgumentException.php +++ b/Exception/TypeErrorInvalidArgumentException.php @@ -2,11 +2,21 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use JetBrains\PhpStorm\Immutable; use JetBrains\PhpStorm\Pure; -use Throwable; #[Immutable] final class TypeErrorInvalidArgumentException extends \InvalidArgumentException @@ -14,12 +24,12 @@ final class TypeErrorInvalidArgumentException extends \InvalidArgumentException private const MESSAGE_TEMPLATE = 'Params have not needed values "%s"'; #[Pure] - private function __construct(string $message, int $code = 0, ?Throwable $previous = null) + private function __construct(string $message, int $code = 0, ?\Throwable $previous = null) { parent::__construct($message, $code, $previous); } - public static function fromParams(array $params, ?Throwable $previous = null): self + public static function fromParams(array $params, ?\Throwable $previous = null): self { $message = sprintf(self::MESSAGE_TEMPLATE, implode(', ', array_keys($params))); diff --git a/Exception/TypeExtractorLocatorException.php b/Exception/TypeExtractorLocatorException.php index 947633b..92f4cbd 100644 --- a/Exception/TypeExtractorLocatorException.php +++ b/Exception/TypeExtractorLocatorException.php @@ -2,13 +2,27 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; +use JetBrains\PhpStorm\Pure; + class TypeExtractorLocatorException extends \LogicException { private const NOT_FOUND_MESSAGE = 'Type extractor not found for "%s:%s"'; - public static function notFound(\ReflectionProperty|\ReflectionParameter $target, bool $wrapCallable = true, ?\Throwable $previous = null): callable|self + #[Pure] + public static function notFound(\ReflectionParameter|\ReflectionProperty $target, bool $wrapCallable = true, ?\Throwable $previous = null): callable|self { $message = sprintf(self::NOT_FOUND_MESSAGE, $target->getDeclaringClass()->getName(), $target->getName()); $exception = new self($message, previous: $previous); diff --git a/Exception/ValidationException.php b/Exception/ValidationException.php index a7632b7..a8dcb39 100644 --- a/Exception/ValidationException.php +++ b/Exception/ValidationException.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Exception; use FRZB\Component\RequestMapper\Data\ErrorInterface as Error; @@ -27,7 +38,6 @@ private function __construct(Error ...$errors) $this->errors = $errors; } - /** @noinspection PhpParamsInspection */ public static function fromConstraintViolationList(ConstraintViolationList $violationList): self { return self::fromConstraintViolations(...$violationList); diff --git a/ExceptionFormatter/ExceptionFormatter.php b/ExceptionFormatter/ExceptionFormatter.php index e5a5347..a7399e9 100644 --- a/ExceptionFormatter/ExceptionFormatter.php +++ b/ExceptionFormatter/ExceptionFormatter.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter; use FRZB\Component\DependencyInjection\Attribute\AsService; @@ -13,8 +24,7 @@ class ExceptionFormatter implements ExceptionFormatterInterface { public function __construct( private readonly ExceptionFormatterLocator $formatterLocator, - ) { - } + ) {} public function format(\Throwable $e): ContractError { diff --git a/ExceptionFormatter/ExceptionFormatterInterface.php b/ExceptionFormatter/ExceptionFormatterInterface.php index e725e3f..f8bdb41 100644 --- a/ExceptionFormatter/ExceptionFormatterInterface.php +++ b/ExceptionFormatter/ExceptionFormatterInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter; use FRZB\Component\DependencyInjection\Attribute\AsAlias; diff --git a/ExceptionFormatter/ExceptionFormatterLocator.php b/ExceptionFormatter/ExceptionFormatterLocator.php index 6e5c246..87e4e68 100644 --- a/ExceptionFormatter/ExceptionFormatterLocator.php +++ b/ExceptionFormatter/ExceptionFormatterLocator.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter; use Fp\Collections\HashMap; @@ -22,7 +33,7 @@ public function __construct( $this->formatters = HashMap::collect($formatters); } - public function get(\Throwable $e): Formatter|callable + public function get(\Throwable $e): callable|Formatter { return $this->formatters ->get($e::class) @@ -32,6 +43,6 @@ public function get(\Throwable $e): Formatter|callable public function has(\Throwable $e): bool { - return $this->formatters->get($e::class)->isNonEmpty(); + return $this->formatters->get($e::class)->isSome(); } } diff --git a/ExceptionFormatter/ExceptionFormatterLocatorInterface.php b/ExceptionFormatter/ExceptionFormatterLocatorInterface.php index 2efa78f..52a7373 100644 --- a/ExceptionFormatter/ExceptionFormatterLocatorInterface.php +++ b/ExceptionFormatter/ExceptionFormatterLocatorInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter; use FRZB\Component\DependencyInjection\Attribute\AsAlias; @@ -10,7 +21,7 @@ #[AsAlias(service: ExceptionFormatterLocator::class)] interface ExceptionFormatterLocatorInterface { - public function get(\Throwable $e): FormatterInterface|callable; + public function get(\Throwable $e): callable|FormatterInterface; public function has(\Throwable $e): bool; } diff --git a/ExceptionFormatter/Formatter/FormatterInterface.php b/ExceptionFormatter/Formatter/FormatterInterface.php index f197eef..07f92bd 100644 --- a/ExceptionFormatter/Formatter/FormatterInterface.php +++ b/ExceptionFormatter/Formatter/FormatterInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter\Formatter; interface FormatterInterface diff --git a/ExceptionFormatter/Formatter/HttpExceptionFormatter.php b/ExceptionFormatter/Formatter/HttpExceptionFormatter.php index 6dad661..0349dc9 100644 --- a/ExceptionFormatter/Formatter/HttpExceptionFormatter.php +++ b/ExceptionFormatter/Formatter/HttpExceptionFormatter.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter\Formatter; use FRZB\Component\DependencyInjection\Attribute\AsService; diff --git a/ExceptionFormatter/Formatter/ThrowableFormatter.php b/ExceptionFormatter/Formatter/ThrowableFormatter.php index 1b29744..f19f41b 100644 --- a/ExceptionFormatter/Formatter/ThrowableFormatter.php +++ b/ExceptionFormatter/Formatter/ThrowableFormatter.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter\Formatter; use FRZB\Component\DependencyInjection\Attribute\AsService; diff --git a/ExceptionFormatter/Formatter/ValidationFormatter.php b/ExceptionFormatter/Formatter/ValidationFormatter.php index 44206ab..5cc7229 100644 --- a/ExceptionFormatter/Formatter/ValidationFormatter.php +++ b/ExceptionFormatter/Formatter/ValidationFormatter.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionFormatter\Formatter; use Fp\Collections\ArrayList; @@ -40,8 +51,7 @@ private static function formatErrors(Error ...$errors): array { return ArrayList::collect($errors) ->map(static fn (Error $error) => [$error->getField() => $error->getMessage()]) - ->reduce(array_merge(...)) - ->getOrElse([]) + ->toMergedArray() ; } } diff --git a/ExceptionMapper/ExceptionMapperLocator.php b/ExceptionMapper/ExceptionMapperLocator.php index 5c3590c..e4f124c 100644 --- a/ExceptionMapper/ExceptionMapperLocator.php +++ b/ExceptionMapper/ExceptionMapperLocator.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionMapper; use Fp\Collections\HashMap; @@ -25,7 +36,7 @@ public function get(\Throwable $exception): ExceptionMapper { return $this->mappers ->get($exception::class) - ->getOrThrow(ExceptionMapperLocatorException::notFound($exception)) + ->getOrElse(fn () => throw ExceptionMapperLocatorException::notFound($exception)) ; } } diff --git a/ExceptionMapper/ExceptionMapperLocatorInterface.php b/ExceptionMapper/ExceptionMapperLocatorInterface.php index fdf93a6..7df7044 100644 --- a/ExceptionMapper/ExceptionMapperLocatorInterface.php +++ b/ExceptionMapper/ExceptionMapperLocatorInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionMapper; use FRZB\Component\DependencyInjection\Attribute\AsAlias; diff --git a/ExceptionMapper/Mapper/ExceptionMapperInterface.php b/ExceptionMapper/Mapper/ExceptionMapperInterface.php index 7a34e99..7189de0 100644 --- a/ExceptionMapper/Mapper/ExceptionMapperInterface.php +++ b/ExceptionMapper/Mapper/ExceptionMapperInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionMapper\Mapper; use FRZB\Component\RequestMapper\Data\ErrorInterface as Error; diff --git a/ExceptionMapper/Mapper/MissingConstructorArgumentsExceptionMapper.php b/ExceptionMapper/Mapper/MissingConstructorArgumentsExceptionMapper.php index c17fa7e..830769d 100644 --- a/ExceptionMapper/Mapper/MissingConstructorArgumentsExceptionMapper.php +++ b/ExceptionMapper/Mapper/MissingConstructorArgumentsExceptionMapper.php @@ -2,9 +2,19 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionMapper\Mapper; -use Fp\Collections\Entry; use Fp\Collections\HashMap; use FRZB\Component\DependencyInjection\Attribute\AsService; use FRZB\Component\DependencyInjection\Attribute\AsTagged; @@ -32,7 +42,7 @@ public function __invoke(MissingConstructorArgumentsException $exception, array $classProperty = ClassHelper::getProperty($className, $parameterName); $propertyName = PropertyHelper::getName($classProperty); $propertyValue = HashMap::collect($payload) - ->filter(static fn (Entry $entry) => str_contains($entry->key, $propertyName)) + ->mapKV(static fn (string $key) => str_contains($key, $propertyName)) ->toArrayList() ->firstElement() ->get() diff --git a/ExceptionMapper/Mapper/TypeErrorExceptionMapper.php b/ExceptionMapper/Mapper/TypeErrorExceptionMapper.php index adca1fd..9e1e746 100644 --- a/ExceptionMapper/Mapper/TypeErrorExceptionMapper.php +++ b/ExceptionMapper/Mapper/TypeErrorExceptionMapper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\ExceptionMapper\Mapper; use FRZB\Component\DependencyInjection\Attribute\AsService; diff --git a/Extractor/ConstraintExtractor.php b/Extractor/ConstraintExtractor.php index a293a4c..a66f0f0 100644 --- a/Extractor/ConstraintExtractor.php +++ b/Extractor/ConstraintExtractor.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Extractor; use Fp\Collections\ArrayList; @@ -18,8 +29,7 @@ class ConstraintExtractor { public function __construct( private readonly TypeExtractorLocator $extractorLocator, - ) { - } + ) {} public function extract(string $className, array $payload = []): ?Collection { @@ -46,7 +56,9 @@ public function extractConstraints(string $className, array $parameters = []): a $propertyTypeName = PropertyHelper::getTypeName($property); $constraints[$propertyName] = match (true) { - $this->extractorLocator->has($property) => ArrayList::collect($propertyValue)->map(fn () => new All($this->extract($this->extractorLocator->get($property)->extract($property), $propertyValue)))->toArray(), + $this->extractorLocator->has($property) => ArrayList::collect($propertyValue) + ->map(fn () => new All($this->extract($this->extractorLocator->get($property)->extract($property), $propertyValue))) + ->toArray(), ClassHelper::isNotBuiltinAndExists($propertyTypeName) => $this->extract($propertyTypeName, $propertyValue), default => ConstraintsHelper::fromProperty($property), }; diff --git a/Extractor/DiscriminatorMapExtractor.php b/Extractor/DiscriminatorMapExtractor.php index fce1355..9233678 100644 --- a/Extractor/DiscriminatorMapExtractor.php +++ b/Extractor/DiscriminatorMapExtractor.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Extractor; use FRZB\Component\DependencyInjection\Attribute\AsService; diff --git a/Extractor/ParametersExtractor.php b/Extractor/ParametersExtractor.php index 1206136..419eaf8 100644 --- a/Extractor/ParametersExtractor.php +++ b/Extractor/ParametersExtractor.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Extractor; use FRZB\Component\DependencyInjection\Attribute\AsService; @@ -14,8 +25,7 @@ class ParametersExtractor { public function __construct( private readonly ClassMapper $classMapper, - ) { - } + ) {} public function extract(string $className, array $payload): array { diff --git a/Helper/AttributeHelper.php b/Helper/AttributeHelper.php index 8673d4d..1eee23f 100644 --- a/Helper/AttributeHelper.php +++ b/Helper/AttributeHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; use Fp\Collections\ArrayList; @@ -11,11 +22,9 @@ #[Immutable] final class AttributeHelper { - private function __construct() - { - } + private function __construct() {} - public static function hasAttribute(\ReflectionProperty|\ReflectionClass|\ReflectionMethod|\ReflectionFunction|\ReflectionParameter $target, string $attributeClass): bool + public static function hasAttribute(\ReflectionClass|\ReflectionFunction|\ReflectionMethod|\ReflectionParameter|\ReflectionProperty $target, string $attributeClass): bool { return null !== self::getAttribute($target, $attributeClass); } @@ -27,7 +36,7 @@ public static function hasAttribute(\ReflectionProperty|\ReflectionClass|\Reflec * * @return null|T */ - public static function getAttribute(\ReflectionProperty|\ReflectionClass|\ReflectionMethod|\ReflectionFunction|\ReflectionParameter $target, string $attributeClass): ?object + public static function getAttribute(\ReflectionClass|\ReflectionFunction|\ReflectionMethod|\ReflectionParameter|\ReflectionProperty $target, string $attributeClass): ?object { return ArrayList::collect(self::getAttributes($target, $attributeClass)) ->firstElement() @@ -42,11 +51,11 @@ public static function getAttribute(\ReflectionProperty|\ReflectionClass|\Reflec * * @return T[] */ - public static function getAttributes(\ReflectionProperty|\ReflectionClass|\ReflectionMethod|\ReflectionFunction|\ReflectionParameter $target, string $attributeClass): array + public static function getAttributes(\ReflectionClass|\ReflectionFunction|\ReflectionMethod|\ReflectionParameter|\ReflectionProperty $target, string $attributeClass): array { return ArrayList::collect($target->getAttributes($attributeClass, \ReflectionAttribute::IS_INSTANCEOF)) ->map(static fn (\ReflectionAttribute $a) => $a->newInstance()) - ->toArray() + ->toList() ; } } diff --git a/Helper/ClassHelper.php b/Helper/ClassHelper.php index 48a5c7d..7d614be 100644 --- a/Helper/ClassHelper.php +++ b/Helper/ClassHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; use Fp\Collections\ArrayList; @@ -12,16 +23,13 @@ #[Immutable] final class ClassHelper { - private function __construct() - { - } + private function __construct() {} public static function isNotBuiltinAndExists(string $className): bool { return (class_exists($className) || interface_exists($className)) && !empty((new \ReflectionClass($className))->getNamespaceName()) - && !self::isEnum($className) - ; + && !self::isEnum($className); } public static function isEnum(string $className): bool @@ -41,8 +49,8 @@ public static function getShortName(string $className): string public static function isNameContains(string $className, string ...$haystack): bool { return ArrayList::collect($haystack) - ->filter(static fn (string $value): bool => StringHelper::contains(self::getShortName($className), $value)) - ->isNonEmpty() + ->first(static fn (string $value): bool => StringHelper::contains(self::getShortName($className), $value)) + ->isSome() ; } @@ -60,7 +68,7 @@ public static function getMethodParameter(string $className, string $classMethod { return ArrayList::collect(self::getMethodParameters($className, $classMethod)) ->first(static fn (\ReflectionParameter $property) => $property->getName() === $parameterName) - ->getOrThrow(HelperException::noMethodParameter($className, $classMethod, $parameterName)) + ->getOrElse(fn () => throw HelperException::noMethodParameter($className, $classMethod, $parameterName)) ; } @@ -78,7 +86,7 @@ public static function getProperty(string $className, string $propertyName): \Re { return ArrayList::collect(self::getProperties($className)) ->first(static fn (\ReflectionProperty $property) => $property->getName() === $propertyName) - ->getOrThrow(HelperException::noClassProperty($className, $propertyName)) + ->getOrElse(fn () => throw HelperException::noClassProperty($className, $propertyName)) ; } @@ -108,7 +116,7 @@ public static function isArrayHasAllPropertiesFromClass(array $array, string $cl * * @return null|T */ - public static function getAttribute(string|object $target, string $attributeClass): ?object + public static function getAttribute(object|string $target, string $attributeClass): ?object { return ArrayList::collect(self::getAttributes($target, $attributeClass)) ->firstElement() @@ -123,7 +131,7 @@ public static function getAttribute(string|object $target, string $attributeClas * * @return array */ - public static function getAttributes(string|object $target, string $attributeClass): array + public static function getAttributes(object|string $target, string $attributeClass): array { try { $attributes = (new \ReflectionClass($target))->getAttributes($attributeClass); @@ -133,7 +141,7 @@ public static function getAttributes(string|object $target, string $attributeCla return ArrayList::collect($attributes) ->map(static fn (\ReflectionAttribute $a) => $a->newInstance()) - ->toArray() + ->toList() ; } } diff --git a/Helper/ConstraintsHelper.php b/Helper/ConstraintsHelper.php index c8c0d48..f385261 100644 --- a/Helper/ConstraintsHelper.php +++ b/Helper/ConstraintsHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; use JetBrains\PhpStorm\Immutable; @@ -12,9 +23,7 @@ #[Immutable] final class ConstraintsHelper { - private function __construct() - { - } + private function __construct() {} public static function createCollection(array $fields, bool $allowExtraFields = true, bool $allowMissingFields = true): Collection { diff --git a/Helper/Header.php b/Helper/Header.php index c8b5d7c..8c094cb 100644 --- a/Helper/Header.php +++ b/Helper/Header.php @@ -4,6 +4,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; /** diff --git a/Helper/HeaderHelper.php b/Helper/HeaderHelper.php index 1ad90e6..6cb2605 100644 --- a/Helper/HeaderHelper.php +++ b/Helper/HeaderHelper.php @@ -2,9 +2,19 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; -use Fp\Collections\Entry; use Fp\Collections\HashMap; use JetBrains\PhpStorm\Immutable; use Symfony\Component\HttpFoundation\Request; @@ -13,16 +23,13 @@ #[Immutable] final class HeaderHelper { - private function __construct() - { - } + private function __construct() {} public static function getHeaders(Request $request): array { return HashMap::collect($request->headers->all()) - ->map(static fn (Entry $e) => current($e->value) ?: null) - ->toAssocArray() - ->getOrElse([]) + ->mapKV(static fn (string $key, array $value) => [$key => current($value) ?: null]) + ->toMergedArray() ; } } diff --git a/Helper/PropertyHelper.php b/Helper/PropertyHelper.php index 3026088..f85ce01 100644 --- a/Helper/PropertyHelper.php +++ b/Helper/PropertyHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; use FRZB\Component\RequestMapper\Exception\InvalidPropertyTypeException; @@ -11,16 +22,14 @@ #[Immutable] final class PropertyHelper { - private function __construct() - { - } + private function __construct() {} - public static function getName(\ReflectionProperty|\ReflectionParameter $property): string + public static function getName(\ReflectionParameter|\ReflectionProperty $property): string { return SerializerHelper::getSerializedNameAttribute($property)->getSerializedName(); } - public static function getTypeName(\ReflectionProperty|\ReflectionParameter $property): ?string + public static function getTypeName(\ReflectionParameter|\ReflectionProperty $property): ?string { $type = $property->getType(); diff --git a/Helper/RequestBodyHelper.php b/Helper/RequestBodyHelper.php index f087e5f..ecd38c0 100644 --- a/Helper/RequestBodyHelper.php +++ b/Helper/RequestBodyHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; use Fp\Collections\ArrayList; @@ -15,9 +26,7 @@ final class RequestBodyHelper { private const REQUEST_POSTFIXES = ['Request', 'Dto', 'DTO']; - private function __construct() - { - } + private function __construct() {} public static function getAttribute(\ReflectionParameter $parameter, array $attributes): ?RequestBody { @@ -38,8 +47,7 @@ public static function fromReflectionAttributes(\ReflectionAttribute ...$attribu return ArrayList::collect($attributes) ->map(static fn (\ReflectionAttribute $ra): RequestBody => $ra->newInstance()) ->map(self::mapAttribute(...)) - ->reduce(array_merge(...)) - ->getOrElse([]) + ->toMergedArray() ; } diff --git a/Helper/SerializerHelper.php b/Helper/SerializerHelper.php index 6f20440..7bb7771 100644 --- a/Helper/SerializerHelper.php +++ b/Helper/SerializerHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; use Fp\Collections\ArrayList; @@ -12,11 +23,9 @@ #[Immutable] final class SerializerHelper { - private function __construct() - { - } + private function __construct() {} - public static function getSerializedNameAttribute(\ReflectionProperty|\ReflectionParameter $rProperty): SerializedName + public static function getSerializedNameAttribute(\ReflectionParameter|\ReflectionProperty $rProperty): SerializedName { return ArrayList::collect(AttributeHelper::getAttributes($rProperty, SerializedName::class)) ->firstElement() diff --git a/Helper/StringHelper.php b/Helper/StringHelper.php index e15ed9f..42e412d 100644 --- a/Helper/StringHelper.php +++ b/Helper/StringHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Helper; use JetBrains\PhpStorm\Immutable; @@ -10,9 +21,7 @@ #[Immutable] final class StringHelper { - private function __construct() - { - } + private function __construct() {} public static function toSnakeCase(string $value): string { diff --git a/PropertyMapper/Mapper/ArrayAsAttributePropertyMapper.php b/PropertyMapper/Mapper/ArrayAsAttributePropertyMapper.php index b851589..ea6a722 100644 --- a/PropertyMapper/Mapper/ArrayAsAttributePropertyMapper.php +++ b/PropertyMapper/Mapper/ArrayAsAttributePropertyMapper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\PropertyMapper\Mapper; use FRZB\Component\DependencyInjection\Attribute\AsService; @@ -14,8 +25,7 @@ class ArrayAsAttributePropertyMapper implements PropertyMapperInterface { public function __construct( private readonly ArrayTypeAttributeExtractor $extractor, - ) { - } + ) {} public function map(\ReflectionProperty $property, mixed $value): array { diff --git a/PropertyMapper/Mapper/BuiltinPropertyMapper.php b/PropertyMapper/Mapper/BuiltinPropertyMapper.php index c52c247..551c5dd 100644 --- a/PropertyMapper/Mapper/BuiltinPropertyMapper.php +++ b/PropertyMapper/Mapper/BuiltinPropertyMapper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\PropertyMapper\Mapper; use FRZB\Component\DependencyInjection\Attribute\AsService; @@ -14,8 +25,7 @@ class BuiltinPropertyMapper implements PropertyMapperInterface { public function __construct( private readonly TypeExtractorLocatorInterface $extractorLocator, - ) { - } + ) {} public function map(\ReflectionProperty $property, mixed $value): array { diff --git a/PropertyMapper/Mapper/DefaultPropertyMapper.php b/PropertyMapper/Mapper/DefaultPropertyMapper.php index b7672dc..e60f1e5 100644 --- a/PropertyMapper/Mapper/DefaultPropertyMapper.php +++ b/PropertyMapper/Mapper/DefaultPropertyMapper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\PropertyMapper\Mapper; use FRZB\Component\DependencyInjection\Attribute\AsService; diff --git a/PropertyMapper/Mapper/DocBlockArrayPropertyMapper.php b/PropertyMapper/Mapper/DocBlockArrayPropertyMapper.php index 9ab44d1..562b902 100644 --- a/PropertyMapper/Mapper/DocBlockArrayPropertyMapper.php +++ b/PropertyMapper/Mapper/DocBlockArrayPropertyMapper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\PropertyMapper\Mapper; use FRZB\Component\DependencyInjection\Attribute\AsService; @@ -14,8 +25,7 @@ final class DocBlockArrayPropertyMapper implements PropertyMapperInterface { public function __construct( private readonly DocBlockTypeExtractor $extractor, - ) { - } + ) {} public function map(\ReflectionProperty $property, mixed $value): array { diff --git a/PropertyMapper/Mapper/PropertyMapperInterface.php b/PropertyMapper/Mapper/PropertyMapperInterface.php index a8fcff9..32a1aec 100644 --- a/PropertyMapper/Mapper/PropertyMapperInterface.php +++ b/PropertyMapper/Mapper/PropertyMapperInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\PropertyMapper\Mapper; interface PropertyMapperInterface diff --git a/PropertyMapper/PropertyMapperLocator.php b/PropertyMapper/PropertyMapperLocator.php index c2a21f0..0d32a69 100644 --- a/PropertyMapper/PropertyMapperLocator.php +++ b/PropertyMapper/PropertyMapperLocator.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\PropertyMapper; use Fp\Collections\ArrayList; @@ -17,7 +28,8 @@ class PropertyMapperLocator implements PropertyMapperLocatorInterface private readonly ArrayList $mappers; public function __construct( - #[TaggedIterator(PropertyMapper::class)] iterable $mappers, + #[TaggedIterator(PropertyMapper::class)] + iterable $mappers, ) { $this->mappers = ArrayList::collect($mappers); } @@ -26,7 +38,7 @@ public function get(\ReflectionProperty $property): PropertyMapper { return $this->mappers ->first(fn (PropertyMapper $pm) => $pm->canMap($property)) - ->getOrThrow(PropertyMapperLocatorException::notFound($property)) + ->getOrElse(fn () => throw PropertyMapperLocatorException::notFound($property)) ; } } diff --git a/PropertyMapper/PropertyMapperLocatorInterface.php b/PropertyMapper/PropertyMapperLocatorInterface.php index 4b1344c..332e0ee 100644 --- a/PropertyMapper/PropertyMapperLocatorInterface.php +++ b/PropertyMapper/PropertyMapperLocatorInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\PropertyMapper; use FRZB\Component\DependencyInjection\Attribute\AsAlias; diff --git a/RequestMapper/RequestMapper.php b/RequestMapper/RequestMapper.php index 405d06b..4174dd6 100644 --- a/RequestMapper/RequestMapper.php +++ b/RequestMapper/RequestMapper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\RequestMapper; use FRZB\Component\DependencyInjection\Attribute\AsService; @@ -25,6 +36,11 @@ #[AsService] class RequestMapper implements RequestMapperInterface { + private const SERIALIZER_CONTEXT = [ + 'disable_type_enforcement' => true, + 'collect_denormalization_errors' => true, + ]; + private const DENORMALIZE_TYPE = 'array'; public function __construct( @@ -34,8 +50,7 @@ public function __construct( private readonly DiscriminatorMapExtractor $classExtractor, private readonly ConstraintExtractor $constraintExtractor, private readonly ParametersExtractor $parametersExtractor, - ) { - } + ) {} public function map(Request $request, RequestBody $attribute): object { diff --git a/RequestMapper/RequestMapperInterface.php b/RequestMapper/RequestMapperInterface.php index 9b61ffe..9064568 100644 --- a/RequestMapper/RequestMapperInterface.php +++ b/RequestMapper/RequestMapperInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\RequestMapper; use FRZB\Component\DependencyInjection\Attribute\AsAlias; diff --git a/RequestMapperBundle.php b/RequestMapperBundle.php index 78daea4..c490548 100644 --- a/RequestMapperBundle.php +++ b/RequestMapperBundle.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/RequestMapperExtension.php b/RequestMapperExtension.php index e4594f3..89b11dc 100644 --- a/RequestMapperExtension.php +++ b/RequestMapperExtension.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper; use Symfony\Component\Config\FileLocator; diff --git a/Resources/bundles.php b/Resources/bundles.php index 7bdbd4f..b9813ff 100644 --- a/Resources/bundles.php +++ b/Resources/bundles.php @@ -2,6 +2,16 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], FRZB\Component\DependencyInjection\DependencyInjectionBundle::class => ['all' => true], diff --git a/Tests/Func/EventListener/JsonRequestListenerTest.php b/Tests/Func/EventListener/JsonRequestListenerTest.php index f160cf6..7eecac8 100644 --- a/Tests/Func/EventListener/JsonRequestListenerTest.php +++ b/Tests/Func/EventListener/JsonRequestListenerTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Func\EventListener; use FRZB\Component\RequestMapper\EventListener\JsonRequestListener; diff --git a/Tests/Func/EventListener/RequestMapperListenerTest.php b/Tests/Func/EventListener/RequestMapperListenerTest.php index 226ff53..d9f8b59 100644 --- a/Tests/Func/EventListener/RequestMapperListenerTest.php +++ b/Tests/Func/EventListener/RequestMapperListenerTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Func\EventListener; use FRZB\Component\RequestMapper\Attribute\RequestBody; @@ -43,7 +54,7 @@ public function testOnKernelController( string $httpMethod, string $targetClass, string $parameterName, - callable|object|array $controller + array|callable|object $controller ): void { $headers = ['content-type' => 'application/json']; $request = RequestHelper::makeRequest(method: $httpMethod, params: $params, headers: $headers); diff --git a/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php b/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php index 4076b9e..c2d4028 100644 --- a/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php +++ b/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Func\ExceptionFormatter; use FRZB\Component\RequestMapper\Data\ErrorContract; diff --git a/Tests/Func/Extractor/ConstraintExtractorTest.php b/Tests/Func/Extractor/ConstraintExtractorTest.php index 0163b3e..8c565e7 100644 --- a/Tests/Func/Extractor/ConstraintExtractorTest.php +++ b/Tests/Func/Extractor/ConstraintExtractorTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Func\Extractor; use FRZB\Component\RequestMapper\Extractor\ConstraintExtractor; diff --git a/Tests/Func/Locator/ExceptionFormatterLocatorTest.php b/Tests/Func/Locator/ExceptionFormatterLocatorTest.php index 9cc5fd0..4841ac7 100644 --- a/Tests/Func/Locator/ExceptionFormatterLocatorTest.php +++ b/Tests/Func/Locator/ExceptionFormatterLocatorTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Func\Locator; use FRZB\Component\RequestMapper\Data\ValidationError; diff --git a/Tests/Func/RequestMapper/RequestMapperTest.php b/Tests/Func/RequestMapper/RequestMapperTest.php index 3a9c560..7ee4e1c 100644 --- a/Tests/Func/RequestMapper/RequestMapperTest.php +++ b/Tests/Func/RequestMapper/RequestMapperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Func\RequestMapper; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Helper/RequestHelper.php b/Tests/Helper/RequestHelper.php index bd4915d..f8cb934 100644 --- a/Tests/Helper/RequestHelper.php +++ b/Tests/Helper/RequestHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Helper; use Symfony\Component\HttpFoundation\HeaderBag; diff --git a/Tests/Helper/TestConstant.php b/Tests/Helper/TestConstant.php index 3afca7c..3902a03 100644 --- a/Tests/Helper/TestConstant.php +++ b/Tests/Helper/TestConstant.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Helper; /** diff --git a/Tests/Stub/Controller/TestCallableController.php b/Tests/Stub/Controller/TestCallableController.php index bc745b4..c75b8dc 100644 --- a/Tests/Stub/Controller/TestCallableController.php +++ b/Tests/Stub/Controller/TestCallableController.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Controller; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Stub/Controller/TestCallableWithoutParameterNameAndParameterClassController.php b/Tests/Stub/Controller/TestCallableWithoutParameterNameAndParameterClassController.php index 11642da..df40f42 100644 --- a/Tests/Stub/Controller/TestCallableWithoutParameterNameAndParameterClassController.php +++ b/Tests/Stub/Controller/TestCallableWithoutParameterNameAndParameterClassController.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Controller; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Stub/Controller/TestCallableWithoutParameterNameController.php b/Tests/Stub/Controller/TestCallableWithoutParameterNameController.php index 67a2081..cf5d27a 100644 --- a/Tests/Stub/Controller/TestCallableWithoutParameterNameController.php +++ b/Tests/Stub/Controller/TestCallableWithoutParameterNameController.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Controller; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Stub/Controller/TestController.php b/Tests/Stub/Controller/TestController.php index fee1b5c..1e38ee0 100644 --- a/Tests/Stub/Controller/TestController.php +++ b/Tests/Stub/Controller/TestController.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Controller; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Stub/Controller/TestWithoutParameterNameAndParameterClassController.php b/Tests/Stub/Controller/TestWithoutParameterNameAndParameterClassController.php index 80ffa2a..a8bf4b3 100644 --- a/Tests/Stub/Controller/TestWithoutParameterNameAndParameterClassController.php +++ b/Tests/Stub/Controller/TestWithoutParameterNameAndParameterClassController.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Controller; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Stub/Controller/TestWithoutParameterNameController.php b/Tests/Stub/Controller/TestWithoutParameterNameController.php index e2fa170..9d5c562 100644 --- a/Tests/Stub/Controller/TestWithoutParameterNameController.php +++ b/Tests/Stub/Controller/TestWithoutParameterNameController.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Controller; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Stub/Enum/TestEnum.php b/Tests/Stub/Enum/TestEnum.php index ebb48c3..a8d0fd8 100644 --- a/Tests/Stub/Enum/TestEnum.php +++ b/Tests/Stub/Enum/TestEnum.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Enum; enum TestEnum: string diff --git a/Tests/Stub/Kernel.php b/Tests/Stub/Kernel.php index 3c2cf88..a559b5d 100644 --- a/Tests/Stub/Kernel.php +++ b/Tests/Stub/Kernel.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; diff --git a/Tests/Stub/Request/CreateCardSettingsRequest.php b/Tests/Stub/Request/CreateCardSettingsRequest.php index c151782..a6b6d1c 100644 --- a/Tests/Stub/Request/CreateCardSettingsRequest.php +++ b/Tests/Stub/Request/CreateCardSettingsRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use JetBrains\PhpStorm\Pure; diff --git a/Tests/Stub/Request/CreateNestedUserRequest.php b/Tests/Stub/Request/CreateNestedUserRequest.php index d4be3eb..1060acc 100644 --- a/Tests/Stub/Request/CreateNestedUserRequest.php +++ b/Tests/Stub/Request/CreateNestedUserRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use Symfony\Component\Validator\Constraints\NotBlank; diff --git a/Tests/Stub/Request/CreateSettingsRequest.php b/Tests/Stub/Request/CreateSettingsRequest.php index 0bd53e5..95a147a 100644 --- a/Tests/Stub/Request/CreateSettingsRequest.php +++ b/Tests/Stub/Request/CreateSettingsRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; @@ -17,8 +28,7 @@ abstract class CreateSettingsRequest { public function __construct( protected string $type - ) { - } + ) {} public function getType(): string { diff --git a/Tests/Stub/Request/CreateUserRequest.php b/Tests/Stub/Request/CreateUserRequest.php index ea0f18c..957808f 100644 --- a/Tests/Stub/Request/CreateUserRequest.php +++ b/Tests/Stub/Request/CreateUserRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use Symfony\Component\Validator\Constraints\NotBlank; diff --git a/Tests/Stub/Request/CreateUserRequestWithEnum.php b/Tests/Stub/Request/CreateUserRequestWithEnum.php index e2bb252..5dc523f 100644 --- a/Tests/Stub/Request/CreateUserRequestWithEnum.php +++ b/Tests/Stub/Request/CreateUserRequestWithEnum.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use FRZB\Component\RequestMapper\Tests\Stub\Enum\TestEnum; diff --git a/Tests/Stub/Request/CreateUserSettingsRequest.php b/Tests/Stub/Request/CreateUserSettingsRequest.php index c98755d..aa805d5 100644 --- a/Tests/Stub/Request/CreateUserSettingsRequest.php +++ b/Tests/Stub/Request/CreateUserSettingsRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use JetBrains\PhpStorm\Pure; diff --git a/Tests/Stub/Request/CreateUserWithSerializedNameRequest.php b/Tests/Stub/Request/CreateUserWithSerializedNameRequest.php index a89d9bf..863f9c9 100644 --- a/Tests/Stub/Request/CreateUserWithSerializedNameRequest.php +++ b/Tests/Stub/Request/CreateUserWithSerializedNameRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use Symfony\Component\Serializer\Annotation\SerializedName; diff --git a/Tests/Stub/Request/TestRequest.php b/Tests/Stub/Request/TestRequest.php index fc979dc..296ea31 100644 --- a/Tests/Stub/Request/TestRequest.php +++ b/Tests/Stub/Request/TestRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; /** @@ -12,6 +23,5 @@ class TestRequest public function __construct( public string $name, public string $model - ) { - } + ) {} } diff --git a/Tests/Stub/Request/TestWithHeadersRequest.php b/Tests/Stub/Request/TestWithHeadersRequest.php index 90193c8..7b56c05 100644 --- a/Tests/Stub/Request/TestWithHeadersRequest.php +++ b/Tests/Stub/Request/TestWithHeadersRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; use FRZB\Component\RequestMapper\Data\HasHeaders; @@ -15,8 +26,7 @@ public function __construct( public string $name, public string $model, public array $headers = [], - ) { - } + ) {} public function setHeaders(array $headers): void { diff --git a/Tests/Stub/Request/TestWithoutParametersRequest.php b/Tests/Stub/Request/TestWithoutParametersRequest.php index 73a3b30..774a932 100644 --- a/Tests/Stub/Request/TestWithoutParametersRequest.php +++ b/Tests/Stub/Request/TestWithoutParametersRequest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Stub\Request; /** diff --git a/Tests/Unit/Attribute/RequestBodyAttributeTest.php b/Tests/Unit/Attribute/RequestBodyAttributeTest.php index 5da6ccf..5570aa3 100644 --- a/Tests/Unit/Attribute/RequestBodyAttributeTest.php +++ b/Tests/Unit/Attribute/RequestBodyAttributeTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Attribute; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Unit/Data/TypeErrorTest.php b/Tests/Unit/Data/TypeErrorTest.php index c0de7c0..3095849 100644 --- a/Tests/Unit/Data/TypeErrorTest.php +++ b/Tests/Unit/Data/TypeErrorTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Data; use FRZB\Component\RequestMapper\Data\TypeError; diff --git a/Tests/Unit/Data/ValidationErrorTest.php b/Tests/Unit/Data/ValidationErrorTest.php index 9134f97..8c9b026 100644 --- a/Tests/Unit/Data/ValidationErrorTest.php +++ b/Tests/Unit/Data/ValidationErrorTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Data; use FRZB\Component\RequestMapper\Data\ValidationError; diff --git a/Tests/Unit/Event/ListenerExceptionEventTest.php b/Tests/Unit/Event/ListenerExceptionEventTest.php index e9f8cac..cf23a23 100644 --- a/Tests/Unit/Event/ListenerExceptionEventTest.php +++ b/Tests/Unit/Event/ListenerExceptionEventTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Event; use FRZB\Component\RequestMapper\Event\ListenerExceptionEvent; diff --git a/Tests/Unit/EventListener/ExceptionListenerTest.php b/Tests/Unit/EventListener/ExceptionListenerTest.php index c7595e1..26bd6b1 100644 --- a/Tests/Unit/EventListener/ExceptionListenerTest.php +++ b/Tests/Unit/EventListener/ExceptionListenerTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\EventListener; use FRZB\Component\RequestMapper\Data\FormattedError; diff --git a/Tests/Unit/EventListener/MergeRequestListenerTest.php b/Tests/Unit/EventListener/MergeRequestListenerTest.php index aae2463..72039be 100644 --- a/Tests/Unit/EventListener/MergeRequestListenerTest.php +++ b/Tests/Unit/EventListener/MergeRequestListenerTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\EventListener; use FRZB\Component\RequestMapper\EventListener\MergeRequestListener; diff --git a/Tests/Unit/EventListener/RequestMapperListenerTest.php b/Tests/Unit/EventListener/RequestMapperListenerTest.php index 8506547..d5162bf 100644 --- a/Tests/Unit/EventListener/RequestMapperListenerTest.php +++ b/Tests/Unit/EventListener/RequestMapperListenerTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\EventListener; use FRZB\Component\RequestMapper\Attribute\RequestBody; @@ -27,7 +38,7 @@ final class RequestMapperListenerTest extends TestCase { #[DataProvider('dataProvider')] - public function testOnKernelController(array $params, string $httpMethod, string $targetClass, string $parameterName, callable|object|array $controller): void + public function testOnKernelController(array $params, string $httpMethod, string $targetClass, string $parameterName, array|callable|object $controller): void { $request = RequestHelper::makeRequest(method: $httpMethod, params: $params); $converter = $this->makeConverter($targetClass, $params); diff --git a/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php b/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php index 83b9552..2604288 100644 --- a/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php +++ b/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\ExceptionMapper\Mapper; use FRZB\Component\RequestMapper\ExceptionMapper\Mapper\TypeErrorExceptionMapper; diff --git a/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php b/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php index 3e0a00e..a4ef280 100644 --- a/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php +++ b/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Extractor; use FRZB\Component\RequestMapper\Exception\ClassExtractorException; diff --git a/Tests/Unit/Extractor/ParametersExtractorTest.php b/Tests/Unit/Extractor/ParametersExtractorTest.php index ec693e5..7a68969 100644 --- a/Tests/Unit/Extractor/ParametersExtractorTest.php +++ b/Tests/Unit/Extractor/ParametersExtractorTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Extractor; use FRZB\Component\PhpDocReader\Reader\ReaderService; diff --git a/Tests/Unit/Helper/ClassHelperTest.php b/Tests/Unit/Helper/ClassHelperTest.php index fe5c9e9..56a1469 100644 --- a/Tests/Unit/Helper/ClassHelperTest.php +++ b/Tests/Unit/Helper/ClassHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Helper; use FRZB\Component\RequestMapper\Helper\ClassHelper; diff --git a/Tests/Unit/Helper/ConstraintHelperTest.php b/Tests/Unit/Helper/ConstraintHelperTest.php index 59f0429..6dc9b53 100644 --- a/Tests/Unit/Helper/ConstraintHelperTest.php +++ b/Tests/Unit/Helper/ConstraintHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Helper; use FRZB\Component\RequestMapper\Helper\ConstraintsHelper; diff --git a/Tests/Unit/Helper/SerializerHelperTest.php b/Tests/Unit/Helper/SerializerHelperTest.php index 836b090..3db63c3 100644 --- a/Tests/Unit/Helper/SerializerHelperTest.php +++ b/Tests/Unit/Helper/SerializerHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Helper; use FRZB\Component\RequestMapper\Helper\SerializerHelper; diff --git a/Tests/Unit/Helper/StringHelperTest.php b/Tests/Unit/Helper/StringHelperTest.php index 1a7c1e9..bdd7261 100644 --- a/Tests/Unit/Helper/StringHelperTest.php +++ b/Tests/Unit/Helper/StringHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Helper; use FRZB\Component\RequestMapper\Helper\StringHelper; diff --git a/Tests/Unit/RequestMapper/RequestMapperTest.php b/Tests/Unit/RequestMapper/RequestMapperTest.php index 50d1e3d..18724fc 100644 --- a/Tests/Unit/RequestMapper/RequestMapperTest.php +++ b/Tests/Unit/RequestMapper/RequestMapperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\RequestMapper; use FRZB\Component\RequestMapper\Attribute\RequestBody; diff --git a/Tests/Unit/Resources/BundlesTest.php b/Tests/Unit/Resources/BundlesTest.php index 9706bb1..3ee0775 100644 --- a/Tests/Unit/Resources/BundlesTest.php +++ b/Tests/Unit/Resources/BundlesTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\Tests\Unit\Resources; use FRZB\Component\DependencyInjection\DependencyInjectionBundle; diff --git a/TypeExtractor/Extractor/ArrayTypeAttributeExtractor.php b/TypeExtractor/Extractor/ArrayTypeAttributeExtractor.php index 2f94a02..3ddeebb 100644 --- a/TypeExtractor/Extractor/ArrayTypeAttributeExtractor.php +++ b/TypeExtractor/Extractor/ArrayTypeAttributeExtractor.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\TypeExtractor\Extractor; use FRZB\Component\DependencyInjection\Attribute\AsService; diff --git a/TypeExtractor/Extractor/DocBlockTypeExtractor.php b/TypeExtractor/Extractor/DocBlockTypeExtractor.php index e96c561..6432e24 100644 --- a/TypeExtractor/Extractor/DocBlockTypeExtractor.php +++ b/TypeExtractor/Extractor/DocBlockTypeExtractor.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\TypeExtractor\Extractor; use FRZB\Component\DependencyInjection\Attribute\AsService; @@ -16,8 +27,7 @@ class DocBlockTypeExtractor implements TypeExtractorInterface { public function __construct( private readonly PhpDocReader $reader, - ) { - } + ) {} public function extract(\ReflectionParameter|\ReflectionProperty $target): ?string { diff --git a/TypeExtractor/Extractor/TypeExtractorInterface.php b/TypeExtractor/Extractor/TypeExtractorInterface.php index 476d4c1..d88ca1c 100644 --- a/TypeExtractor/Extractor/TypeExtractorInterface.php +++ b/TypeExtractor/Extractor/TypeExtractorInterface.php @@ -2,11 +2,22 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\TypeExtractor\Extractor; interface TypeExtractorInterface { - public function extract(\ReflectionProperty|\ReflectionParameter $target): ?string; + public function extract(\ReflectionParameter|\ReflectionProperty $target): ?string; - public function canExtract(\ReflectionProperty|\ReflectionParameter $target): bool; + public function canExtract(\ReflectionParameter|\ReflectionProperty $target): bool; } diff --git a/TypeExtractor/TypeExtractorLocator.php b/TypeExtractor/TypeExtractorLocator.php index 5b3b138..cfc2f46 100644 --- a/TypeExtractor/TypeExtractorLocator.php +++ b/TypeExtractor/TypeExtractorLocator.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\TypeExtractor; use Fp\Collections\ArrayList; @@ -17,16 +28,17 @@ class TypeExtractorLocator implements TypeExtractorLocatorInterface private readonly ArrayList $extractors; public function __construct( - #[TaggedIterator(TypeExtractor::class)] iterable $extractors, + #[TaggedIterator(TypeExtractor::class)] + iterable $extractors, ) { $this->extractors = ArrayList::collect($extractors); } - public function get(\ReflectionProperty|\ReflectionParameter $target): TypeExtractor + public function get(\ReflectionParameter|\ReflectionProperty $target): TypeExtractor { return $this->extractors ->first(static fn (TypeExtractor $extractor) => $extractor->canExtract($target)) - ->getOrThrow(TypeExtractorLocatorException::notFound($target)) + ->getOrElse(fn () => throw TypeExtractorLocatorException::notFound($target)) ; } @@ -34,7 +46,7 @@ public function has(\ReflectionParameter|\ReflectionProperty $target): bool { return $this->extractors ->first(static fn (TypeExtractor $extractor) => $extractor->canExtract($target)) - ->isNonEmpty() + ->isSome() ; } } diff --git a/TypeExtractor/TypeExtractorLocatorInterface.php b/TypeExtractor/TypeExtractorLocatorInterface.php index d480d8b..17832a8 100644 --- a/TypeExtractor/TypeExtractorLocatorInterface.php +++ b/TypeExtractor/TypeExtractorLocatorInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2023 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\RequestMapper\TypeExtractor; use FRZB\Component\DependencyInjection\Attribute\AsAlias; @@ -10,7 +21,7 @@ #[AsAlias(TypeExtractorLocator::class)] interface TypeExtractorLocatorInterface { - public function get(\ReflectionProperty|\ReflectionParameter $target): TypeExtractor; + public function get(\ReflectionParameter|\ReflectionProperty $target): TypeExtractor; - public function has(\ReflectionProperty|\ReflectionParameter $target): bool; + public function has(\ReflectionParameter|\ReflectionProperty $target): bool; } diff --git a/composer.json b/composer.json index 78c7a3d..405501e 100644 --- a/composer.json +++ b/composer.json @@ -26,25 +26,25 @@ ], "require": { "php": ">=8.1", - "fp4php/functional": "^4.20|^6", - "symfony/dependency-injection": "^5.4|^6|7", - "symfony/http-kernel": "^5.4|^6|7", - "symfony/framework-bundle": "^5.4|^6|^7", + "fp4php/functional": "^6.0", + "symfony/dependency-injection": "^6.0|^7.0", + "symfony/http-kernel": "^6.0|^7.0", + "symfony/framework-bundle": "^6.0|^7.0", "symfony/serializer-pack": "^1.3", - "symfony/validator": "^5.4|^6|7", - "symfony/event-dispatcher": "^5.4|^6|7", - "frzb/dependency-injection": "^1.8", - "frzb/php-doc-reader": "^1.0", - "symfony/yaml": "^5.4|^6|7", - "symfony/property-access": "^5.4|^6|7", - "symfony/uid": "^5.4|^6|^7" + "symfony/validator": "^6.0|^7.0", + "symfony/event-dispatcher": "^6.0|^7.0", + "frzb/dependency-injection": "^2.0", + "frzb/php-doc-reader": "^2.0", + "symfony/yaml": "^6.0|^7.0", + "symfony/property-access": "^6.0|^7.0", + "symfony/uid": "^6.0|^7.0" }, "require-dev": { "phpunit/phpunit": "^10.5", "phpunit/php-code-coverage": "^10.1", "php-coveralls/php-coveralls": "^2.7", - "symfony/phpunit-bridge": "^5.4|^6|7", - "friendsofphp/php-cs-fixer": "^3.41", + "symfony/phpunit-bridge": "^6.0|^7.0", + "friendsofphp/php-cs-fixer": "^3.42", "symfony/test-pack": "^1.0.10" }, "autoload": {