From 9ca8a216560d8c00da7f814ea40e47564a45ff03 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sat, 27 May 2023 11:43:07 +0300 Subject: [PATCH 01/11] Use parameter name as key for array attributes (#9) --- src/Attribute/Parameter/BodyResolver.php | 6 +----- src/Attribute/Parameter/QueryResolver.php | 5 +---- src/Attribute/Parameter/RequestResolver.php | 5 +---- src/Attribute/Parameter/UploadedFilesResolver.php | 5 +---- tests/Attribute/Parameter/BodyTest.php | 9 +++++---- tests/Attribute/Parameter/QueryTest.php | 9 +++++---- tests/Attribute/Parameter/RequestTest.php | 9 +++++---- tests/Attribute/Parameter/UploadedFilesTest.php | 10 ++++++---- 8 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/Attribute/Parameter/BodyResolver.php b/src/Attribute/Parameter/BodyResolver.php index b28f176..7922031 100644 --- a/src/Attribute/Parameter/BodyResolver.php +++ b/src/Attribute/Parameter/BodyResolver.php @@ -5,7 +5,6 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Yiisoft\Arrays\ArrayHelper; - use Yiisoft\Hydrator\Context; use Yiisoft\Hydrator\NotResolvedException; use Yiisoft\Hydrator\ParameterAttributeInterface; @@ -30,10 +29,7 @@ public function getParameterValue(ParameterAttributeInterface $attribute, Contex $parsedBody = $this->requestProvider->get()->getParsedBody(); - $name = $attribute->getName(); - if ($name === null) { - return $parsedBody; - } + $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!is_array($parsedBody)) { throw new NotResolvedException(); diff --git a/src/Attribute/Parameter/QueryResolver.php b/src/Attribute/Parameter/QueryResolver.php index b96db7b..3cd19c8 100644 --- a/src/Attribute/Parameter/QueryResolver.php +++ b/src/Attribute/Parameter/QueryResolver.php @@ -27,10 +27,7 @@ public function getParameterValue(ParameterAttributeInterface $attribute, Contex $params = $this->requestProvider->get()->getQueryParams(); - $name = $attribute->getName(); - if ($name === null) { - return $params; - } + $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!ArrayHelper::pathExists($params, $name)) { throw new NotResolvedException(); diff --git a/src/Attribute/Parameter/RequestResolver.php b/src/Attribute/Parameter/RequestResolver.php index b1cd110..2fd070d 100644 --- a/src/Attribute/Parameter/RequestResolver.php +++ b/src/Attribute/Parameter/RequestResolver.php @@ -27,10 +27,7 @@ public function getParameterValue(ParameterAttributeInterface $attribute, Contex $requestAttributes = $this->requestProvider->get()->getAttributes(); - $name = $attribute->getName(); - if ($name === null) { - return $requestAttributes; - } + $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!ArrayHelper::pathExists($requestAttributes, $name)) { throw new NotResolvedException(); diff --git a/src/Attribute/Parameter/UploadedFilesResolver.php b/src/Attribute/Parameter/UploadedFilesResolver.php index 71efc37..1e4cf9f 100644 --- a/src/Attribute/Parameter/UploadedFilesResolver.php +++ b/src/Attribute/Parameter/UploadedFilesResolver.php @@ -30,10 +30,7 @@ public function getParameterValue( $files = $this->requestProvider->get()->getUploadedFiles(); - $name = $attribute->getName(); - if ($name === null) { - return $files; - } + $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!ArrayHelper::pathExists($files, $name)) { throw new NotResolvedException(); diff --git a/tests/Attribute/Parameter/BodyTest.php b/tests/Attribute/Parameter/BodyTest.php index 3e1bc8f..76bde90 100644 --- a/tests/Attribute/Parameter/BodyTest.php +++ b/tests/Attribute/Parameter/BodyTest.php @@ -23,6 +23,7 @@ public function testBase(): void $hydrator = $this->createHydrator([ 'a' => 'one', 'b' => 'two', + 'c' => 'three', ]); $input = new class () { @@ -31,14 +32,14 @@ public function testBase(): void #[Body('b')] public string $b = ''; #[Body] - public array $all = []; + public string $c = ''; }; $hydrator->hydrate($input); $this->assertSame('one', $input->a); $this->assertSame('two', $input->b); - $this->assertSame(['a' => 'one', 'b' => 'two'], $input->all); + $this->assertSame('three', $input->c); } public function testWithoutBody(): void @@ -51,14 +52,14 @@ public function testWithoutBody(): void #[Body('b')] public string $b = ''; #[Body] - public array $all = []; + public string $c = ''; }; $hydrator->hydrate($input); $this->assertSame('', $input->a); $this->assertSame('', $input->b); - $this->assertSame([], $input->all); + $this->assertSame('', $input->c); } public function testNonExistPath(): void diff --git a/tests/Attribute/Parameter/QueryTest.php b/tests/Attribute/Parameter/QueryTest.php index e08e47b..46830b5 100644 --- a/tests/Attribute/Parameter/QueryTest.php +++ b/tests/Attribute/Parameter/QueryTest.php @@ -23,6 +23,7 @@ public function testBase(): void $hydrator = $this->createHydrator([ 'a' => 'one', 'b' => 'two', + 'c' => 'three', ]); $input = new class () { @@ -31,14 +32,14 @@ public function testBase(): void #[Query('b')] public string $b = ''; #[Query] - public array $all = []; + public string $c = ''; }; $hydrator->hydrate($input); $this->assertSame('one', $input->a); $this->assertSame('two', $input->b); - $this->assertSame(['a' => 'one', 'b' => 'two'], $input->all); + $this->assertSame('three', $input->c); } public function testWithoutBody(): void @@ -51,14 +52,14 @@ public function testWithoutBody(): void #[Query('b')] public string $b = ''; #[Query] - public array $all = []; + public string $c = ''; }; $hydrator->hydrate($input); $this->assertSame('', $input->a); $this->assertSame('', $input->b); - $this->assertSame([], $input->all); + $this->assertSame('', $input->c); } public function testNonExistPath(): void diff --git a/tests/Attribute/Parameter/RequestTest.php b/tests/Attribute/Parameter/RequestTest.php index ccf7f23..7311ef7 100644 --- a/tests/Attribute/Parameter/RequestTest.php +++ b/tests/Attribute/Parameter/RequestTest.php @@ -23,6 +23,7 @@ public function testBase(): void $hydrator = $this->createHydrator([ 'a' => 'one', 'b' => 'two', + 'c' => 'three', ]); $input = new class () { @@ -31,14 +32,14 @@ public function testBase(): void #[Request('b')] public string $b = ''; #[Request] - public array $all = []; + public string $c = ''; }; $hydrator->hydrate($input); $this->assertSame('one', $input->a); $this->assertSame('two', $input->b); - $this->assertSame(['a' => 'one', 'b' => 'two'], $input->all); + $this->assertSame('three', $input->c); } public function testWithoutBody(): void @@ -51,14 +52,14 @@ public function testWithoutBody(): void #[Request('b')] public string $b = ''; #[Request] - public array $all = []; + public string $c = ''; }; $hydrator->hydrate($input); $this->assertSame('', $input->a); $this->assertSame('', $input->b); - $this->assertSame([], $input->all); + $this->assertSame('', $input->c); } public function testNonExistPath(): void diff --git a/tests/Attribute/Parameter/UploadedFilesTest.php b/tests/Attribute/Parameter/UploadedFilesTest.php index c8563f0..0e6048f 100644 --- a/tests/Attribute/Parameter/UploadedFilesTest.php +++ b/tests/Attribute/Parameter/UploadedFilesTest.php @@ -23,10 +23,12 @@ public function testBase(): void { $file1 = $this->createMock(UploadedFileInterface::class); $file2 = $this->createMock(UploadedFileInterface::class); + $file3 = $this->createMock(UploadedFileInterface::class); $hydrator = $this->createHydrator([ 'a' => $file1, 'b' => $file2, + 'c' => $file3, ]); $input = new class () { @@ -35,14 +37,14 @@ public function testBase(): void #[UploadedFiles('b')] public ?UploadedFileInterface $b = null; #[UploadedFiles] - public array $all = []; + public ?UploadedFileInterface $c = null; }; $hydrator->hydrate($input); $this->assertSame($file1, $input->a); $this->assertSame($file2, $input->b); - $this->assertSame(['a' => $file1, 'b' => $file2], $input->all); + $this->assertSame($file3, $input->c); } public function testWithoutBody(): void @@ -55,14 +57,14 @@ public function testWithoutBody(): void #[UploadedFiles('b')] public ?UploadedFileInterface $b = null; #[UploadedFiles] - public array $all = []; + public ?UploadedFileInterface $c = null; }; $hydrator->hydrate($input); $this->assertNull($input->a); $this->assertNull($input->b); - $this->assertSame([], $input->all); + $this->assertNull($input->c); } public function testNonExistPath(): void From 42a7e3c000b9ac171a8b1331eb4cab29860f5f85 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sat, 27 May 2023 12:23:34 +0300 Subject: [PATCH 02/11] Adapt to last changes in hydrator (#10) * Adapt to last changes in `yiisoft/hydrator` * adapt --- src/Attribute/Parameter/BodyResolver.php | 10 +++++----- src/Attribute/Parameter/QueryResolver.php | 8 ++++---- src/Attribute/Parameter/RequestResolver.php | 8 ++++---- src/Attribute/Parameter/UploadedFilesResolver.php | 14 +++++--------- src/HydratorAttributeParametersResolver.php | 10 +++------- tests/Support/CallableTypeCaster.php | 5 +++-- tests/Support/TestHelper.php | 3 ++- 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/Attribute/Parameter/BodyResolver.php b/src/Attribute/Parameter/BodyResolver.php index 7922031..ec32e7e 100644 --- a/src/Attribute/Parameter/BodyResolver.php +++ b/src/Attribute/Parameter/BodyResolver.php @@ -6,9 +6,9 @@ use Yiisoft\Arrays\ArrayHelper; use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\NotResolvedException; use Yiisoft\Hydrator\ParameterAttributeInterface; use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Result; use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; @@ -21,7 +21,7 @@ public function __construct( ) { } - public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): mixed + public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result { if (!$attribute instanceof Body) { throw new UnexpectedAttributeException(Body::class, $attribute); @@ -32,13 +32,13 @@ public function getParameterValue(ParameterAttributeInterface $attribute, Contex $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!is_array($parsedBody)) { - throw new NotResolvedException(); + return Result::fail(); } if (!ArrayHelper::pathExists($parsedBody, $name)) { - throw new NotResolvedException(); + return Result::fail(); } - return ArrayHelper::getValueByPath($parsedBody, $name); + return Result::success(ArrayHelper::getValueByPath($parsedBody, $name)); } } diff --git a/src/Attribute/Parameter/QueryResolver.php b/src/Attribute/Parameter/QueryResolver.php index 3cd19c8..5f099ca 100644 --- a/src/Attribute/Parameter/QueryResolver.php +++ b/src/Attribute/Parameter/QueryResolver.php @@ -6,9 +6,9 @@ use Yiisoft\Arrays\ArrayHelper; use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\NotResolvedException; use Yiisoft\Hydrator\ParameterAttributeInterface; use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Result; use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; @@ -19,7 +19,7 @@ public function __construct( ) { } - public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): mixed + public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result { if (!$attribute instanceof Query) { throw new UnexpectedAttributeException(Query::class, $attribute); @@ -30,9 +30,9 @@ public function getParameterValue(ParameterAttributeInterface $attribute, Contex $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!ArrayHelper::pathExists($params, $name)) { - throw new NotResolvedException(); + return Result::fail(); } - return ArrayHelper::getValueByPath($params, $name); + return Result::success(ArrayHelper::getValueByPath($params, $name)); } } diff --git a/src/Attribute/Parameter/RequestResolver.php b/src/Attribute/Parameter/RequestResolver.php index 2fd070d..52ad080 100644 --- a/src/Attribute/Parameter/RequestResolver.php +++ b/src/Attribute/Parameter/RequestResolver.php @@ -6,9 +6,9 @@ use Yiisoft\Arrays\ArrayHelper; use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\NotResolvedException; use Yiisoft\Hydrator\ParameterAttributeInterface; use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Result; use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; @@ -19,7 +19,7 @@ public function __construct( ) { } - public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): mixed + public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result { if (!$attribute instanceof Request) { throw new UnexpectedAttributeException(Request::class, $attribute); @@ -30,9 +30,9 @@ public function getParameterValue(ParameterAttributeInterface $attribute, Contex $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!ArrayHelper::pathExists($requestAttributes, $name)) { - throw new NotResolvedException(); + return Result::fail(); } - return ArrayHelper::getValueByPath($requestAttributes, $name); + return Result::success(ArrayHelper::getValueByPath($requestAttributes, $name)); } } diff --git a/src/Attribute/Parameter/UploadedFilesResolver.php b/src/Attribute/Parameter/UploadedFilesResolver.php index 1e4cf9f..705dc96 100644 --- a/src/Attribute/Parameter/UploadedFilesResolver.php +++ b/src/Attribute/Parameter/UploadedFilesResolver.php @@ -4,12 +4,11 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; -use Psr\Http\Message\UploadedFileInterface; use Yiisoft\Arrays\ArrayHelper; use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\NotResolvedException; use Yiisoft\Hydrator\ParameterAttributeInterface; use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Result; use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; @@ -20,10 +19,8 @@ public function __construct( ) { } - public function getParameterValue( - ParameterAttributeInterface $attribute, - Context $context - ): array|UploadedFileInterface { + public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result + { if (!$attribute instanceof UploadedFiles) { throw new UnexpectedAttributeException(UploadedFiles::class, $attribute); } @@ -33,10 +30,9 @@ public function getParameterValue( $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!ArrayHelper::pathExists($files, $name)) { - throw new NotResolvedException(); + return Result::fail(); } - /** @var UploadedFileInterface */ - return ArrayHelper::getValueByPath($files, $name); + return Result::success(ArrayHelper::getValueByPath($files, $name)); } } diff --git a/src/HydratorAttributeParametersResolver.php b/src/HydratorAttributeParametersResolver.php index 5e98eda..96d4e25 100644 --- a/src/HydratorAttributeParametersResolver.php +++ b/src/HydratorAttributeParametersResolver.php @@ -6,7 +6,6 @@ use Psr\Container\ContainerInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Hydrator\NotResolvedException; use Yiisoft\Hydrator\ParameterAttributesHandler; use Yiisoft\Hydrator\TypeCaster\SimpleTypeCaster; use Yiisoft\Hydrator\TypeCasterInterface; @@ -28,13 +27,10 @@ public function resolve(array $parameters, ServerRequestInterface $request): arr $result = []; foreach ($parameters as $parameter) { - try { - $value = $this->handler->handle($parameter); - } catch (NotResolvedException) { - continue; + $handleResult = $this->handler->handle($parameter); + if ($handleResult->isResolved()) { + $result[$parameter->getName()] = $handleResult->getValue(); } - - $result[$parameter->getName()] = $value; } return $result; diff --git a/tests/Support/CallableTypeCaster.php b/tests/Support/CallableTypeCaster.php index a2ad58e..cfe684a 100644 --- a/tests/Support/CallableTypeCaster.php +++ b/tests/Support/CallableTypeCaster.php @@ -5,6 +5,7 @@ namespace Yiisoft\Input\Http\Tests\Support; use ReflectionType; +use Yiisoft\Hydrator\Result; use Yiisoft\Hydrator\TypeCasterInterface; final class CallableTypeCaster implements TypeCasterInterface @@ -14,8 +15,8 @@ public function __construct( ) { } - public function cast(mixed $value, ?ReflectionType $type): mixed + public function cast(mixed $value, ?ReflectionType $type): Result { - return ($this->callable)($value); + return Result::success(($this->callable)($value)); } } diff --git a/tests/Support/TestHelper.php b/tests/Support/TestHelper.php index 7ab1c3f..c5a32cb 100644 --- a/tests/Support/TestHelper.php +++ b/tests/Support/TestHelper.php @@ -10,6 +10,7 @@ use ReflectionParameter; use Yiisoft\Hydrator\Context; use Yiisoft\Hydrator\Hydrator; +use Yiisoft\Hydrator\Result; use Yiisoft\Hydrator\Validator\Attribute\ValidateResolver; use Yiisoft\Hydrator\Validator\ValidatingHydrator; use Yiisoft\Input\Http\Attribute\Data\FromQueryResolver; @@ -22,7 +23,7 @@ final class TestHelper { public static function createContext(): Context { - return new Context(self::getParameters(static fn(int $a) => null)['a'], false, null, [], []); + return new Context(self::getParameters(static fn(int $a) => null)['a'], Result::fail(), [], []); } /** From 77d0bd508be131018784c345d77c4862f7d71cfc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 09:21:40 +0300 Subject: [PATCH 03/11] Update rector/rector requirement from ^0.16.0 to ^0.17.0 (#11) Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.16.0...0.17.0) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8e2dd7c..ee5d9df 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require-dev": { "maglnet/composer-require-checker": "^4.4", "phpunit/phpunit": "^9.5", - "rector/rector": "^0.16.0", + "rector/rector": "^0.17.0", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", "vimeo/psalm": "^4.30|^5.7", From 1c990c3a97ec5270d3399f2064763fcabc03245d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:28:25 +0000 Subject: [PATCH 04/11] Update rector/rector requirement from ^0.17.0 to ^0.18.0 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.17.0...0.18.0) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ee5d9df..17bcc67 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require-dev": { "maglnet/composer-require-checker": "^4.4", "phpunit/phpunit": "^9.5", - "rector/rector": "^0.17.0", + "rector/rector": "^0.18.0", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", "vimeo/psalm": "^4.30|^5.7", From cf92da13ac4028e026b62644448ed1f04814be95 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 5 Oct 2023 13:35:33 +0300 Subject: [PATCH 05/11] Adapt to last changes in hydrator + Update GitHub actions (#15) --- .github/workflows/bc.yml_ | 23 +++++++- .github/workflows/build.yml | 3 +- .../workflows/composer-require-checker.yml | 3 +- .github/workflows/mutation.yml | 1 + .github/workflows/rector.yml | 4 +- .github/workflows/static.yml | 3 +- rector.php | 2 + src/Attribute/Data/FromBody.php | 6 +- src/Attribute/Data/FromBodyResolver.php | 24 ++++---- src/Attribute/Data/FromQuery.php | 6 +- src/Attribute/Data/FromQueryResolver.php | 22 ++++--- src/Attribute/Parameter/Body.php | 2 +- src/Attribute/Parameter/BodyResolver.php | 14 +++-- src/Attribute/Parameter/Query.php | 2 +- src/Attribute/Parameter/QueryResolver.php | 14 +++-- src/Attribute/Parameter/Request.php | 2 +- src/Attribute/Parameter/RequestResolver.php | 14 +++-- src/Attribute/Parameter/UploadedFiles.php | 2 +- .../Parameter/UploadedFilesResolver.php | 14 +++-- src/HydratorAttributeParametersResolver.php | 35 +++++++++--- tests/Attribute/Data/FromBodyTest.php | 16 +++--- tests/Attribute/Data/FromQueryTest.php | 16 +++--- tests/Attribute/Parameter/BodyTest.php | 13 ++--- tests/Attribute/Parameter/QueryTest.php | 13 ++--- tests/Attribute/Parameter/RequestTest.php | 13 ++--- .../Attribute/Parameter/UploadedFilesTest.php | 13 ++--- ...ydratorAttributeParametersResolverTest.php | 7 +-- tests/Support/CallableTypeCaster.php | 6 +- tests/Support/TestHelper.php | 57 +++++++++++++++---- 29 files changed, 213 insertions(+), 137 deletions(-) diff --git a/.github/workflows/bc.yml_ b/.github/workflows/bc.yml_ index 7fec32c..00041a9 100644 --- a/.github/workflows/bc.yml_ +++ b/.github/workflows/bc.yml_ @@ -1,6 +1,25 @@ on: - - pull_request - - push + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + - 'psalm.xml' + push: + branches: ['master'] + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + - 'psalm.xml' name: backwards compatibility diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f12ea5e..fb1f560 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,7 @@ on: - 'psalm.xml' push: + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -28,4 +29,4 @@ jobs: os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['8.1', '8.2'] + ['8.0', '8.1', '8.2'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 0474238..c166d27 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -11,6 +11,7 @@ on: - 'psalm.xml' push: + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -30,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2'] + ['8.0', '8.1', '8.2'] diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 03b72c0..8150499 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -9,6 +9,7 @@ on: - 'psalm.xml' push: + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index c9030d7..bd79331 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -14,8 +14,10 @@ name: rector jobs: rector: uses: yiisoft/actions/.github/workflows/rector.yml@master + secrets: + token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} with: os: >- ['ubuntu-latest'] php: >- - ['8.1'] + ['8.2'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 301ab7c..970abaa 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -10,6 +10,7 @@ on: - 'phpunit.xml.dist' push: + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -28,4 +29,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2'] + ['8.0', '8.1', '8.2'] diff --git a/rector.php b/rector.php index f55daae..c80d86e 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; +use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; use Rector\Set\ValueObject\LevelSetList; @@ -23,5 +24,6 @@ $rectorConfig->skip([ ClosureToArrowFunctionRector::class, + JsonThrowOnErrorRector::class, ]); }; diff --git a/src/Attribute/Data/FromBody.php b/src/Attribute/Data/FromBody.php index 120174d..8f2487a 100644 --- a/src/Attribute/Data/FromBody.php +++ b/src/Attribute/Data/FromBody.php @@ -5,11 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Data; use Attribute; -use Yiisoft\Hydrator\DataAttributeInterface; -use Yiisoft\Hydrator\HydratorInterface; +use Yiisoft\Hydrator\ArrayData; +use Yiisoft\Hydrator\Attribute\Data\DataAttributeInterface; /** - * @psalm-import-type MapType from HydratorInterface + * @psalm-import-type MapType from ArrayData */ #[Attribute(Attribute::TARGET_CLASS)] final class FromBody implements DataAttributeInterface diff --git a/src/Attribute/Data/FromBodyResolver.php b/src/Attribute/Data/FromBodyResolver.php index 86c8e34..a29fc19 100644 --- a/src/Attribute/Data/FromBodyResolver.php +++ b/src/Attribute/Data/FromBodyResolver.php @@ -5,10 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Data; use Yiisoft\Arrays\ArrayHelper; -use Yiisoft\Hydrator\Data; -use Yiisoft\Hydrator\DataAttributeInterface; -use Yiisoft\Hydrator\DataAttributeResolverInterface; -use Yiisoft\Hydrator\UnexpectedAttributeException; +use Yiisoft\Hydrator\ArrayData; +use Yiisoft\Hydrator\Attribute\Data\DataAttributeInterface; +use Yiisoft\Hydrator\Attribute\Data\DataAttributeResolverInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; +use Yiisoft\Hydrator\DataInterface; use Yiisoft\Input\Http\Request\RequestProviderInterface; use function is_array; @@ -20,26 +21,27 @@ public function __construct( ) { } - public function prepareData(DataAttributeInterface $attribute, Data $data): void + public function prepareData(DataAttributeInterface $attribute, DataInterface $data): DataInterface { if (!$attribute instanceof FromBody) { throw new UnexpectedAttributeException(FromBody::class, $attribute); } + $array = []; + $parsedBody = $this->requestProvider->get()->getParsedBody(); if (is_array($parsedBody)) { $name = $attribute->getName(); if ($name === null) { - $data->setData($parsedBody); + $array = $parsedBody; } else { $value = ArrayHelper::getValueByPath($parsedBody, $name); - $data->setData(is_array($value) ? $value : []); + if (is_array($value)) { + $array = $value; + } } - } else { - $data->setData([]); } - $data->setMap($attribute->getMap()); - $data->setStrict($attribute->isStrict()); + return new ArrayData($array, $attribute->getMap(), $attribute->isStrict()); } } diff --git a/src/Attribute/Data/FromQuery.php b/src/Attribute/Data/FromQuery.php index ecb6107..7fc1fc8 100644 --- a/src/Attribute/Data/FromQuery.php +++ b/src/Attribute/Data/FromQuery.php @@ -5,11 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Data; use Attribute; -use Yiisoft\Hydrator\DataAttributeInterface; -use Yiisoft\Hydrator\HydratorInterface; +use Yiisoft\Hydrator\ArrayData; +use Yiisoft\Hydrator\Attribute\Data\DataAttributeInterface; /** - * @psalm-import-type MapType from HydratorInterface + * @psalm-import-type MapType from ArrayData */ #[Attribute(Attribute::TARGET_CLASS)] final class FromQuery implements DataAttributeInterface diff --git a/src/Attribute/Data/FromQueryResolver.php b/src/Attribute/Data/FromQueryResolver.php index e321888..1513cc2 100644 --- a/src/Attribute/Data/FromQueryResolver.php +++ b/src/Attribute/Data/FromQueryResolver.php @@ -5,10 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Data; use Yiisoft\Arrays\ArrayHelper; -use Yiisoft\Hydrator\Data; -use Yiisoft\Hydrator\DataAttributeInterface; -use Yiisoft\Hydrator\DataAttributeResolverInterface; -use Yiisoft\Hydrator\UnexpectedAttributeException; +use Yiisoft\Hydrator\ArrayData; +use Yiisoft\Hydrator\Attribute\Data\DataAttributeInterface; +use Yiisoft\Hydrator\Attribute\Data\DataAttributeResolverInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; +use Yiisoft\Hydrator\DataInterface; use Yiisoft\Input\Http\Request\RequestProviderInterface; use function is_array; @@ -20,23 +21,26 @@ public function __construct( ) { } - public function prepareData(DataAttributeInterface $attribute, Data $data): void + public function prepareData(DataAttributeInterface $attribute, DataInterface $data): DataInterface { if (!$attribute instanceof FromQuery) { throw new UnexpectedAttributeException(FromQuery::class, $attribute); } + $array = []; + $params = $this->requestProvider->get()->getQueryParams(); $name = $attribute->getName(); if ($name === null) { - $data->setData($params); + $array = $params; } else { $value = ArrayHelper::getValueByPath($params, $name); - $data->setData(is_array($value) ? $value : []); + if (is_array($value)) { + $array = $value; + } } - $data->setMap($attribute->getMap()); - $data->setStrict($attribute->isStrict()); + return new ArrayData($array, $attribute->getMap(), $attribute->isStrict()); } } diff --git a/src/Attribute/Parameter/Body.php b/src/Attribute/Parameter/Body.php index 3b07f52..18d471f 100644 --- a/src/Attribute/Parameter/Body.php +++ b/src/Attribute/Parameter/Body.php @@ -5,7 +5,7 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Attribute; -use Yiisoft\Hydrator\ParameterAttributeInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; #[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER | Attribute::IS_REPEATABLE)] final class Body implements ParameterAttributeInterface diff --git a/src/Attribute/Parameter/BodyResolver.php b/src/Attribute/Parameter/BodyResolver.php index ec32e7e..6fcc49f 100644 --- a/src/Attribute/Parameter/BodyResolver.php +++ b/src/Attribute/Parameter/BodyResolver.php @@ -5,11 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Yiisoft\Arrays\ArrayHelper; -use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\ParameterAttributeInterface; -use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext; use Yiisoft\Hydrator\Result; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; use function is_array; @@ -21,8 +21,10 @@ public function __construct( ) { } - public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result - { + public function getParameterValue( + ParameterAttributeInterface $attribute, + ParameterAttributeResolveContext $context, + ): Result { if (!$attribute instanceof Body) { throw new UnexpectedAttributeException(Body::class, $attribute); } diff --git a/src/Attribute/Parameter/Query.php b/src/Attribute/Parameter/Query.php index 9c5aa7e..a1e36ef 100644 --- a/src/Attribute/Parameter/Query.php +++ b/src/Attribute/Parameter/Query.php @@ -5,7 +5,7 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Attribute; -use Yiisoft\Hydrator\ParameterAttributeInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; #[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER | Attribute::IS_REPEATABLE)] final class Query implements ParameterAttributeInterface diff --git a/src/Attribute/Parameter/QueryResolver.php b/src/Attribute/Parameter/QueryResolver.php index 5f099ca..f044139 100644 --- a/src/Attribute/Parameter/QueryResolver.php +++ b/src/Attribute/Parameter/QueryResolver.php @@ -5,11 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Yiisoft\Arrays\ArrayHelper; -use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\ParameterAttributeInterface; -use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; use Yiisoft\Hydrator\Result; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; final class QueryResolver implements ParameterAttributeResolverInterface @@ -19,8 +19,10 @@ public function __construct( ) { } - public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result - { + public function getParameterValue( + ParameterAttributeInterface $attribute, + ParameterAttributeResolveContext $context, + ): Result { if (!$attribute instanceof Query) { throw new UnexpectedAttributeException(Query::class, $attribute); } diff --git a/src/Attribute/Parameter/Request.php b/src/Attribute/Parameter/Request.php index fffb061..b3cfc41 100644 --- a/src/Attribute/Parameter/Request.php +++ b/src/Attribute/Parameter/Request.php @@ -5,7 +5,7 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Attribute; -use Yiisoft\Hydrator\ParameterAttributeInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; #[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER | Attribute::IS_REPEATABLE)] final class Request implements ParameterAttributeInterface diff --git a/src/Attribute/Parameter/RequestResolver.php b/src/Attribute/Parameter/RequestResolver.php index 52ad080..6f307a7 100644 --- a/src/Attribute/Parameter/RequestResolver.php +++ b/src/Attribute/Parameter/RequestResolver.php @@ -5,11 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Yiisoft\Arrays\ArrayHelper; -use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\ParameterAttributeInterface; -use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext; use Yiisoft\Hydrator\Result; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; final class RequestResolver implements ParameterAttributeResolverInterface @@ -19,8 +19,10 @@ public function __construct( ) { } - public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result - { + public function getParameterValue( + ParameterAttributeInterface $attribute, + ParameterAttributeResolveContext $context, + ): Result { if (!$attribute instanceof Request) { throw new UnexpectedAttributeException(Request::class, $attribute); } diff --git a/src/Attribute/Parameter/UploadedFiles.php b/src/Attribute/Parameter/UploadedFiles.php index 1a59674..ada670e 100644 --- a/src/Attribute/Parameter/UploadedFiles.php +++ b/src/Attribute/Parameter/UploadedFiles.php @@ -5,7 +5,7 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Attribute; -use Yiisoft\Hydrator\ParameterAttributeInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; #[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] final class UploadedFiles implements ParameterAttributeInterface diff --git a/src/Attribute/Parameter/UploadedFilesResolver.php b/src/Attribute/Parameter/UploadedFilesResolver.php index 705dc96..831eddd 100644 --- a/src/Attribute/Parameter/UploadedFilesResolver.php +++ b/src/Attribute/Parameter/UploadedFilesResolver.php @@ -5,11 +5,11 @@ namespace Yiisoft\Input\Http\Attribute\Parameter; use Yiisoft\Arrays\ArrayHelper; -use Yiisoft\Hydrator\Context; -use Yiisoft\Hydrator\ParameterAttributeInterface; -use Yiisoft\Hydrator\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface; +use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeResolverInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext; use Yiisoft\Hydrator\Result; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Request\RequestProviderInterface; final class UploadedFilesResolver implements ParameterAttributeResolverInterface @@ -19,8 +19,10 @@ public function __construct( ) { } - public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result - { + public function getParameterValue( + ParameterAttributeInterface $attribute, + ParameterAttributeResolveContext $context, + ): Result { if (!$attribute instanceof UploadedFiles) { throw new UnexpectedAttributeException(UploadedFiles::class, $attribute); } diff --git a/src/HydratorAttributeParametersResolver.php b/src/HydratorAttributeParametersResolver.php index 96d4e25..94f9c6a 100644 --- a/src/HydratorAttributeParametersResolver.php +++ b/src/HydratorAttributeParametersResolver.php @@ -4,22 +4,29 @@ namespace Yiisoft\Input\Http; -use Psr\Container\ContainerInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Hydrator\ParameterAttributesHandler; -use Yiisoft\Hydrator\TypeCaster\SimpleTypeCaster; -use Yiisoft\Hydrator\TypeCasterInterface; +use ReflectionParameter; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributesHandler; +use Yiisoft\Hydrator\Hydrator; +use Yiisoft\Hydrator\HydratorInterface; +use Yiisoft\Hydrator\Result; +use Yiisoft\Hydrator\TypeCaster\PhpNativeTypeCaster; +use Yiisoft\Hydrator\TypeCaster\TypeCastContext; +use Yiisoft\Hydrator\TypeCaster\TypeCasterInterface; use Yiisoft\Middleware\Dispatcher\ParametersResolverInterface; final class HydratorAttributeParametersResolver implements ParametersResolverInterface { - private ParameterAttributesHandler $handler; + private TypeCasterInterface $typeCaster; + private HydratorInterface $hydrator; public function __construct( - ContainerInterface $container, + private ParameterAttributesHandler $handler, ?TypeCasterInterface $typeCaster = null, + ?HydratorInterface $hydrator = null, ) { - $this->handler = new ParameterAttributesHandler($container, $typeCaster ?? new SimpleTypeCaster()); + $this->typeCaster = $typeCaster ?? new PhpNativeTypeCaster(); + $this->hydrator = $hydrator ?? new Hydrator(typeCaster: $this->typeCaster); } public function resolve(array $parameters, ServerRequestInterface $request): array @@ -29,10 +36,22 @@ public function resolve(array $parameters, ServerRequestInterface $request): arr foreach ($parameters as $parameter) { $handleResult = $this->handler->handle($parameter); if ($handleResult->isResolved()) { - $result[$parameter->getName()] = $handleResult->getValue(); + $result[$parameter->getName()] = $this->prepareValue($handleResult, $parameter); } } return $result; } + + public function prepareValue(Result $handleResult, ReflectionParameter $parameter): mixed + { + $value = $handleResult->getValue(); + + $typeCastResult = $this->typeCaster->cast( + $value, + new TypeCastContext($this->hydrator, $parameter) + ); + + return $typeCastResult->isResolved() ? $typeCastResult->getValue() : $value; + } } diff --git a/tests/Attribute/Data/FromBodyTest.php b/tests/Attribute/Data/FromBodyTest.php index eccf4d9..743c1b0 100644 --- a/tests/Attribute/Data/FromBodyTest.php +++ b/tests/Attribute/Data/FromBodyTest.php @@ -6,9 +6,9 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Hydrator\Data; +use Yiisoft\Hydrator\ArrayData; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; use Yiisoft\Hydrator\Hydrator; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Attribute\Data\FromBody; use Yiisoft\Input\Http\Attribute\Data\FromBodyResolver; use Yiisoft\Input\Http\Attribute\Data\FromQuery; @@ -16,7 +16,7 @@ use Yiisoft\Input\Http\Request\RequestProviderInterface; use Yiisoft\Input\Http\Tests\Support\Input\FromBodyInput; use Yiisoft\Input\Http\Tests\Support\Input\FromBodyNestedInput; -use Yiisoft\Test\Support\Container\SimpleContainer; +use Yiisoft\Input\Http\Tests\Support\TestHelper; final class FromBodyTest extends TestCase { @@ -65,7 +65,7 @@ public function testUnexpectedAttributeException(): void $resolver = new FromBodyResolver($this->createMock(RequestProviderInterface::class)); $attribute = new FromQuery(); - $data = new Data(); + $data = new ArrayData(); $this->expectException(UnexpectedAttributeException::class); $this->expectExceptionMessage('Expected "' . FromBody::class . '", but "' . FromQuery::class . '" given.'); @@ -80,10 +80,8 @@ private function createHydrator(mixed $parsedBody): Hydrator $requestProvider = new RequestProvider(); $requestProvider->set($request); - return new Hydrator( - new SimpleContainer([ - FromBodyResolver::class => new FromBodyResolver($requestProvider), - ]), - ); + return TestHelper::createHydrator([ + FromBodyResolver::class => new FromBodyResolver($requestProvider), + ]); } } diff --git a/tests/Attribute/Data/FromQueryTest.php b/tests/Attribute/Data/FromQueryTest.php index 7619d8f..3554e89 100644 --- a/tests/Attribute/Data/FromQueryTest.php +++ b/tests/Attribute/Data/FromQueryTest.php @@ -6,9 +6,9 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Hydrator\Data; +use Yiisoft\Hydrator\ArrayData; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; use Yiisoft\Hydrator\Hydrator; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Attribute\Data\FromBody; use Yiisoft\Input\Http\Attribute\Data\FromQuery; use Yiisoft\Input\Http\Attribute\Data\FromQueryResolver; @@ -16,7 +16,7 @@ use Yiisoft\Input\Http\Request\RequestProviderInterface; use Yiisoft\Input\Http\Tests\Support\Input\FromQueryInput; use Yiisoft\Input\Http\Tests\Support\Input\FromQueryNestedInput; -use Yiisoft\Test\Support\Container\SimpleContainer; +use Yiisoft\Input\Http\Tests\Support\TestHelper; final class FromQueryTest extends TestCase { @@ -65,7 +65,7 @@ public function testUnexpectedAttributeException(): void $resolver = new FromQueryResolver($this->createMock(RequestProviderInterface::class)); $attribute = new FromBody(); - $data = new Data(); + $data = new ArrayData(); $this->expectException(UnexpectedAttributeException::class); $this->expectExceptionMessage('Expected "' . FromQuery::class . '", but "' . FromBody::class . '" given.'); @@ -80,10 +80,8 @@ private function createHydrator(array $queryParams): Hydrator $requestProvider = new RequestProvider(); $requestProvider->set($request); - return new Hydrator( - new SimpleContainer([ - FromQueryResolver::class => new FromQueryResolver($requestProvider), - ]), - ); + return TestHelper::createHydrator([ + FromQueryResolver::class => new FromQueryResolver($requestProvider), + ]); } } diff --git a/tests/Attribute/Parameter/BodyTest.php b/tests/Attribute/Parameter/BodyTest.php index 76bde90..9322cd7 100644 --- a/tests/Attribute/Parameter/BodyTest.php +++ b/tests/Attribute/Parameter/BodyTest.php @@ -6,15 +6,14 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; use Yiisoft\Hydrator\Hydrator; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Attribute\Parameter\Body; use Yiisoft\Input\Http\Attribute\Parameter\BodyResolver; use Yiisoft\Input\Http\Attribute\Parameter\Query; use Yiisoft\Input\Http\Request\RequestProvider; use Yiisoft\Input\Http\Request\RequestProviderInterface; use Yiisoft\Input\Http\Tests\Support\TestHelper; -use Yiisoft\Test\Support\Container\SimpleContainer; final class BodyTest extends TestCase { @@ -84,7 +83,7 @@ public function testUnexpectedAttributeException(): void $resolver = new BodyResolver($this->createMock(RequestProviderInterface::class)); $attribute = new Query(); - $context = TestHelper::createContext(); + $context = TestHelper::createParameterAttributeResolveContext(); $this->expectException(UnexpectedAttributeException::class); $this->expectExceptionMessage('Expected "' . Body::class . '", but "' . Query::class . '" given.'); @@ -99,10 +98,8 @@ private function createHydrator(mixed $parsedBody): Hydrator $requestProvider = new RequestProvider(); $requestProvider->set($request); - return new Hydrator( - new SimpleContainer([ - BodyResolver::class => new BodyResolver($requestProvider), - ]), - ); + return TestHelper::createHydrator([ + BodyResolver::class => new BodyResolver($requestProvider), + ]); } } diff --git a/tests/Attribute/Parameter/QueryTest.php b/tests/Attribute/Parameter/QueryTest.php index 46830b5..5ee7f74 100644 --- a/tests/Attribute/Parameter/QueryTest.php +++ b/tests/Attribute/Parameter/QueryTest.php @@ -6,15 +6,14 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; use Yiisoft\Hydrator\Hydrator; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Attribute\Parameter\Body; use Yiisoft\Input\Http\Attribute\Parameter\Query; use Yiisoft\Input\Http\Attribute\Parameter\QueryResolver; use Yiisoft\Input\Http\Request\RequestProvider; use Yiisoft\Input\Http\Request\RequestProviderInterface; use Yiisoft\Input\Http\Tests\Support\TestHelper; -use Yiisoft\Test\Support\Container\SimpleContainer; final class QueryTest extends TestCase { @@ -84,7 +83,7 @@ public function testUnexpectedAttributeException(): void $resolver = new QueryResolver($this->createMock(RequestProviderInterface::class)); $attribute = new Body(); - $context = TestHelper::createContext(); + $context = TestHelper::createParameterAttributeResolveContext(); $this->expectException(UnexpectedAttributeException::class); $this->expectExceptionMessage('Expected "' . Query::class . '", but "' . Body::class . '" given.'); @@ -99,10 +98,8 @@ private function createHydrator(array $queryParams): Hydrator $requestProvider = new RequestProvider(); $requestProvider->set($request); - return new Hydrator( - new SimpleContainer([ - QueryResolver::class => new QueryResolver($requestProvider), - ]), - ); + return TestHelper::createHydrator([ + QueryResolver::class => new QueryResolver($requestProvider), + ]); } } diff --git a/tests/Attribute/Parameter/RequestTest.php b/tests/Attribute/Parameter/RequestTest.php index 7311ef7..4df768b 100644 --- a/tests/Attribute/Parameter/RequestTest.php +++ b/tests/Attribute/Parameter/RequestTest.php @@ -6,15 +6,14 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; use Yiisoft\Hydrator\Hydrator; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Attribute\Parameter\Body; use Yiisoft\Input\Http\Attribute\Parameter\Request; use Yiisoft\Input\Http\Attribute\Parameter\RequestResolver; use Yiisoft\Input\Http\Request\RequestProvider; use Yiisoft\Input\Http\Request\RequestProviderInterface; use Yiisoft\Input\Http\Tests\Support\TestHelper; -use Yiisoft\Test\Support\Container\SimpleContainer; final class RequestTest extends TestCase { @@ -84,7 +83,7 @@ public function testUnexpectedAttributeException(): void $resolver = new RequestResolver($this->createMock(RequestProviderInterface::class)); $attribute = new Body(); - $context = TestHelper::createContext(); + $context = TestHelper::createParameterAttributeResolveContext(); $this->expectException(UnexpectedAttributeException::class); $this->expectExceptionMessage('Expected "' . Request::class . '", but "' . Body::class . '" given.'); @@ -99,10 +98,8 @@ private function createHydrator(array $attributes): Hydrator $requestProvider = new RequestProvider(); $requestProvider->set($request); - return new Hydrator( - new SimpleContainer([ - RequestResolver::class => new RequestResolver($requestProvider), - ]), - ); + return TestHelper::createHydrator([ + RequestResolver::class => new RequestResolver($requestProvider), + ]); } } diff --git a/tests/Attribute/Parameter/UploadedFilesTest.php b/tests/Attribute/Parameter/UploadedFilesTest.php index 0e6048f..9839c2e 100644 --- a/tests/Attribute/Parameter/UploadedFilesTest.php +++ b/tests/Attribute/Parameter/UploadedFilesTest.php @@ -7,15 +7,14 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\UploadedFileInterface; +use Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException; use Yiisoft\Hydrator\Hydrator; -use Yiisoft\Hydrator\UnexpectedAttributeException; use Yiisoft\Input\Http\Attribute\Parameter\Body; use Yiisoft\Input\Http\Attribute\Parameter\UploadedFiles; use Yiisoft\Input\Http\Attribute\Parameter\UploadedFilesResolver; use Yiisoft\Input\Http\Request\RequestProvider; use Yiisoft\Input\Http\Request\RequestProviderInterface; use Yiisoft\Input\Http\Tests\Support\TestHelper; -use Yiisoft\Test\Support\Container\SimpleContainer; final class UploadedFilesTest extends TestCase { @@ -89,7 +88,7 @@ public function testUnexpectedAttributeException(): void $resolver = new UploadedFilesResolver($this->createMock(RequestProviderInterface::class)); $attribute = new Body(); - $context = TestHelper::createContext(); + $context = TestHelper::createParameterAttributeResolveContext(); $this->expectException(UnexpectedAttributeException::class); $this->expectExceptionMessage('Expected "' . UploadedFiles::class . '", but "' . Body::class . '" given.'); @@ -104,10 +103,8 @@ private function createHydrator(array $uploadedFiles): Hydrator $requestProvider = new RequestProvider(); $requestProvider->set($request); - return new Hydrator( - new SimpleContainer([ - UploadedFilesResolver::class => new UploadedFilesResolver($requestProvider), - ]), - ); + return TestHelper::createHydrator([ + UploadedFilesResolver::class => new UploadedFilesResolver($requestProvider), + ]); } } diff --git a/tests/HydratorAttributeParametersResolverTest.php b/tests/HydratorAttributeParametersResolverTest.php index a2a4f6d..c934047 100644 --- a/tests/HydratorAttributeParametersResolverTest.php +++ b/tests/HydratorAttributeParametersResolverTest.php @@ -14,7 +14,6 @@ use Yiisoft\Input\Http\Request\RequestProvider; use Yiisoft\Input\Http\Tests\Support\CallableTypeCaster; use Yiisoft\Input\Http\Tests\Support\TestHelper; -use Yiisoft\Test\Support\Container\SimpleContainer; final class HydratorAttributeParametersResolverTest extends TestCase { @@ -28,10 +27,10 @@ public function testBase(): void $requestProvider->set($request); $resolver = new HydratorAttributeParametersResolver( - new SimpleContainer([ + TestHelper::createParameterAttributesHandler([ QueryResolver::class => new QueryResolver($requestProvider), BodyResolver::class => new BodyResolver($requestProvider), - ]), + ]) ); $parameters = TestHelper::getParameters( @@ -61,7 +60,7 @@ public function testTypeCasting(): void $requestProvider->set($request); $resolver = new HydratorAttributeParametersResolver( - new SimpleContainer([ + TestHelper::createParameterAttributesHandler([ QueryResolver::class => new QueryResolver($requestProvider), ]), new CallableTypeCaster( diff --git a/tests/Support/CallableTypeCaster.php b/tests/Support/CallableTypeCaster.php index cfe684a..d733ee8 100644 --- a/tests/Support/CallableTypeCaster.php +++ b/tests/Support/CallableTypeCaster.php @@ -4,9 +4,9 @@ namespace Yiisoft\Input\Http\Tests\Support; -use ReflectionType; use Yiisoft\Hydrator\Result; -use Yiisoft\Hydrator\TypeCasterInterface; +use Yiisoft\Hydrator\TypeCaster\TypeCastContext; +use Yiisoft\Hydrator\TypeCaster\TypeCasterInterface; final class CallableTypeCaster implements TypeCasterInterface { @@ -15,7 +15,7 @@ public function __construct( ) { } - public function cast(mixed $value, ?ReflectionType $type): Result + public function cast(mixed $value, TypeCastContext $context): Result { return Result::success(($this->callable)($value)); } diff --git a/tests/Support/TestHelper.php b/tests/Support/TestHelper.php index c5a32cb..98aa960 100644 --- a/tests/Support/TestHelper.php +++ b/tests/Support/TestHelper.php @@ -8,11 +8,16 @@ use Psr\Http\Message\ServerRequestInterface; use ReflectionFunction; use ReflectionParameter; -use Yiisoft\Hydrator\Context; +use Yiisoft\Hydrator\ArrayData; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributesHandler; +use Yiisoft\Hydrator\AttributeHandling\ResolverFactory\ContainerAttributeResolverFactory; use Yiisoft\Hydrator\Hydrator; +use Yiisoft\Hydrator\ObjectFactory\ContainerObjectFactory; use Yiisoft\Hydrator\Result; use Yiisoft\Hydrator\Validator\Attribute\ValidateResolver; use Yiisoft\Hydrator\Validator\ValidatingHydrator; +use Yiisoft\Injector\Injector; use Yiisoft\Input\Http\Attribute\Data\FromQueryResolver; use Yiisoft\Input\Http\Request\RequestProvider; use Yiisoft\Input\Http\RequestInputParametersResolver; @@ -21,9 +26,41 @@ final class TestHelper { - public static function createContext(): Context + public static function createHydrator(?array $definitions = null): Hydrator { - return new Context(self::getParameters(static fn(int $a) => null)['a'], Result::fail(), [], []); + if ($definitions === null) { + return new Hydrator(); + } + + $container = new SimpleContainer( + $definitions, + static fn(string $class) => new $class(), + ); + + return new Hydrator( + attributeResolverFactory: new ContainerAttributeResolverFactory($container), + objectFactory: new ContainerObjectFactory( + new Injector($container) + ), + ); + } + + public static function createParameterAttributesHandler(array $definitions): ParameterAttributesHandler + { + return new ParameterAttributesHandler( + new ContainerAttributeResolverFactory( + new SimpleContainer($definitions) + ) + ); + } + + public static function createParameterAttributeResolveContext(): ParameterAttributeResolveContext + { + return new ParameterAttributeResolveContext( + self::getParameters(static fn(int $a) => null)['a'], + Result::fail(), + new ArrayData(), + ); } /** @@ -51,21 +88,17 @@ public static function createRequestInputParametersResolver( $validator = new Validator(); $validateResolver = new ValidateResolver($validator); - $container = new SimpleContainer( - [ - ValidateResolver::class => $validateResolver, - FromQueryResolver::class => new FromQueryResolver($requestProvider), - ], - ); + $hydrator = self::createHydrator([ + ValidateResolver::class => $validateResolver, + FromQueryResolver::class => new FromQueryResolver($requestProvider), + ]); if ($useValidatingHydrator) { $hydrator = new ValidatingHydrator( - new Hydrator($container), + $hydrator, $validator, $validateResolver, ); - } else { - $hydrator = new Hydrator($container); } return new RequestInputParametersResolver( From 2be779eb24432c9c3b6575fad6ef261e3e9b8c4e Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 9 Nov 2023 20:40:37 +0300 Subject: [PATCH 06/11] MSI 100% (#16) --- .github/workflows/mutation.yml | 1 + src/HydratorAttributeParametersResolver.php | 2 +- tests/Request/RequestNotSetExceptionTest.php | 20 +++++++ tests/RequestInputParametersResolverTest.php | 63 +++++++++++++++++--- tests/Support/PureObject.php | 9 +++ tests/Support/TestHelper.php | 9 ++- 6 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 tests/Request/RequestNotSetExceptionTest.php create mode 100644 tests/Support/PureObject.php diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 8150499..68ad08d 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -24,6 +24,7 @@ jobs: mutation: uses: yiisoft/actions/.github/workflows/roave-infection.yml@master with: + min-covered-msi: 100 os: >- ['ubuntu-latest'] php: >- diff --git a/src/HydratorAttributeParametersResolver.php b/src/HydratorAttributeParametersResolver.php index 94f9c6a..2d26535 100644 --- a/src/HydratorAttributeParametersResolver.php +++ b/src/HydratorAttributeParametersResolver.php @@ -43,7 +43,7 @@ public function resolve(array $parameters, ServerRequestInterface $request): arr return $result; } - public function prepareValue(Result $handleResult, ReflectionParameter $parameter): mixed + private function prepareValue(Result $handleResult, ReflectionParameter $parameter): mixed { $value = $handleResult->getValue(); diff --git a/tests/Request/RequestNotSetExceptionTest.php b/tests/Request/RequestNotSetExceptionTest.php new file mode 100644 index 0000000..b040208 --- /dev/null +++ b/tests/Request/RequestNotSetExceptionTest.php @@ -0,0 +1,20 @@ +assertSame('Request is not set.', $exception->getMessage()); + $this->assertSame(0, $exception->getCode()); + $this->assertNull($exception->getPrevious()); + } +} diff --git a/tests/RequestInputParametersResolverTest.php b/tests/RequestInputParametersResolverTest.php index a129aba..25cd562 100644 --- a/tests/RequestInputParametersResolverTest.php +++ b/tests/RequestInputParametersResolverTest.php @@ -4,11 +4,13 @@ namespace Yiisoft\Input\Http\Tests; +use Closure; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Input\Http\InputValidationException; use Yiisoft\Input\Http\Tests\Support\Input\PersonInput; use Yiisoft\Input\Http\Tests\Support\Input\SimpleRequestInput; +use Yiisoft\Input\Http\Tests\Support\PureObject; use Yiisoft\Input\Http\Tests\Support\TestHelper; final class RequestInputParametersResolverTest extends TestCase @@ -16,24 +18,69 @@ final class RequestInputParametersResolverTest extends TestCase public function testBase(): void { $request = $this->createMock(ServerRequestInterface::class); - $request->method('getQueryParams')->willReturn([]); + $request->method('getQueryParams')->willReturn(['a' => '1', 'b' => '2']); $resolver = TestHelper::createRequestInputParametersResolver($request); - $parameters = TestHelper::getParameters(static fn(PersonInput $input) => null); + $parameters = TestHelper::getParameters(static fn(PersonInput $person, SimpleRequestInput $simple) => null); $result = $resolver->resolve($parameters, $request); - $this->assertSame(['input'], array_keys($result)); + $this->assertSame(['person', 'simple'], array_keys($result)); - /** @var PersonInput $input */ - $input = $result['input']; + /** @var PersonInput $person */ + $person = $result['person']; - $this->assertInstanceOf(PersonInput::class, $input); - $this->assertFalse($input->getValidationResult()->isValid()); + /** @var SimpleRequestInput $simple */ + $simple = $result['simple']; + + $this->assertInstanceOf(PersonInput::class, $person); + $this->assertFalse($person->getValidationResult()->isValid()); $this->assertSame( ['name' => ['Value cannot be blank.']], - $input->getValidationResult()->getErrorMessagesIndexedByPath() + $person->getValidationResult()->getErrorMessagesIndexedByPath() ); + + $this->assertInstanceOf(SimpleRequestInput::class, $simple); + $this->assertSame('1', $simple->a); + $this->assertSame('2', $simple->b); + } + + public function dataParameters(): array + { + return [ + [ + ['person' => PersonInput::class, 'simple' => SimpleRequestInput::class], + static fn(PersonInput $person, SimpleRequestInput $simple) => null, + ], + [ + ['person' => PersonInput::class], + static fn(PersonInput $person, PureObject $object) => null, + ], + [ + ['simple' => SimpleRequestInput::class], + static fn(PureObject|SimpleRequestInput $object, SimpleRequestInput $simple) => null, + ], + ]; + } + + /** + * @dataProvider dataParameters + */ + public function testParameters(array $expected, Closure $closure): void + { + $request = $this->createMock(ServerRequestInterface::class); + $request->method('getQueryParams')->willReturn(['a' => '1', 'b' => '2']); + + $resolver = TestHelper::createRequestInputParametersResolver($request); + $parameters = TestHelper::getParameters($closure); + + $result = $resolver->resolve($parameters, $request); + + $this->assertSame(array_keys($expected), array_keys($result)); + + foreach ($result as $name => $value) { + $this->assertInstanceOf($expected[$name], $value); + } } public function testWithNonValidatingHydrator(): void diff --git a/tests/Support/PureObject.php b/tests/Support/PureObject.php new file mode 100644 index 0000000..8049d78 --- /dev/null +++ b/tests/Support/PureObject.php @@ -0,0 +1,9 @@ +set($request); @@ -101,9 +101,8 @@ public static function createRequestInputParametersResolver( ); } - return new RequestInputParametersResolver( - $hydrator, - $throwInputValidationException, - ); + return $throwInputValidationException === null + ? new RequestInputParametersResolver($hydrator) + : new RequestInputParametersResolver($hydrator, $throwInputValidationException); } } From eb3d20fca9dde99bc77793ceaf0135593473d92a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 27 Dec 2023 23:30:10 +0300 Subject: [PATCH 07/11] Improve CI (#18) --- .github/PULL_REQUEST_TEMPLATE.md | 1 - .github/workflows/build.yml | 3 ++- .github/workflows/composer-require-checker.yml | 2 +- .github/workflows/rector.yml | 2 +- .github/workflows/static.yml | 2 +- phpunit.xml.dist | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index cecccf6..6be5d58 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,4 +3,3 @@ | Is bugfix? | ✔️/❌ | New feature? | ✔️/❌ | Breaks BC? | ✔️/❌ -| Fixed issues | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb1f560..11d50bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,8 @@ jobs: phpunit: uses: yiisoft/actions/.github/workflows/phpunit.yml@master with: + ini-values: pcov.directory=$GITHUB_WORKSPACE, pcov.exclude=#^(?!($GITHUB_WORKSPACE/config/|$GITHUB_WORKSPACE/src/)).*# os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.0', '8.1', '8.2', '8.3'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index c166d27..5473ec9 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.0', '8.1', '8.2', '8.3'] diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index bd79331..35411d0 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -20,4 +20,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.2'] + ['8.3'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 970abaa..8694d2d 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -29,4 +29,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.0', '8.1', '8.2', '8.3'] diff --git a/phpunit.xml.dist b/phpunit.xml.dist index dbb362b..6ce0a67 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -30,6 +30,7 @@ ./src + ./config From 7ab60348f9b33fd6f0ede998383ed669fcaf70e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 08:51:03 +0300 Subject: [PATCH 08/11] Update rector/rector requirement from ^0.18.0 to ^0.19.0 (#19) Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.18.0...0.19.0) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 17bcc67..cb46985 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require-dev": { "maglnet/composer-require-checker": "^4.4", "phpunit/phpunit": "^9.5", - "rector/rector": "^0.18.0", + "rector/rector": "^0.19.0", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", "vimeo/psalm": "^4.30|^5.7", From b78cdf89342313f37d5b067bbff62a094bcda59d Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 29 Jan 2024 13:48:22 +0300 Subject: [PATCH 09/11] Use stable yiisoft/hydrator --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cb46985..023d2fc 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "psr/http-server-handler": "^1.0", "psr/http-server-middleware": "^1.0", "yiisoft/arrays": "^3.0", - "yiisoft/hydrator": "dev-master", + "yiisoft/hydrator": "^1.0", "yiisoft/hydrator-validator": "dev-master", "yiisoft/middleware-dispatcher": "^5.1", "yiisoft/validator": "^1.1" From 3827c0f08ea59d7df9ac0b367844e198ff5f4f52 Mon Sep 17 00:00:00 2001 From: Schiopu Alexandru <44147615+thenotsoft@users.noreply.github.com> Date: Sun, 4 Feb 2024 12:26:28 +0200 Subject: [PATCH 10/11] Use stable `yiisoft/hydrator-validator` (#20) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 023d2fc..ce7e67b 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "psr/http-server-middleware": "^1.0", "yiisoft/arrays": "^3.0", "yiisoft/hydrator": "^1.0", - "yiisoft/hydrator-validator": "dev-master", + "yiisoft/hydrator-validator": "^1.0", "yiisoft/middleware-dispatcher": "^5.1", "yiisoft/validator": "^1.1" }, From 9b6eb9a99bba8d7254a1d35058c1482497015ca2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 06:37:26 +0300 Subject: [PATCH 11/11] Update rector/rector requirement from ^0.19.0 to ^1.0.0 (#21) Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.19.0...1.0.0) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ce7e67b..02c6d51 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require-dev": { "maglnet/composer-require-checker": "^4.4", "phpunit/phpunit": "^9.5", - "rector/rector": "^0.19.0", + "rector/rector": "^1.0.0", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", "vimeo/psalm": "^4.30|^5.7",