From a2a09fcb3d7c381a7887ef021aed592cef705b09 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Sun, 14 Nov 2021 20:15:51 +0900 Subject: [PATCH] Soothe sa --- src/AbstractRequest.php | 4 + .../Interceptor/JsonSchemaInterceptor.php | 2 +- tests/Module/JsonSchemaFakeModuleTest.php | 6 ++ tests/Module/JsonSchemaModuleTest.php | 9 ++ tests/ResourceTest.php | 7 ++ vendor-bin/tools/composer.lock | 82 +++++++++---------- 6 files changed, 68 insertions(+), 42 deletions(-) diff --git a/src/AbstractRequest.php b/src/AbstractRequest.php index adc919de..be2c5d4c 100644 --- a/src/AbstractRequest.php +++ b/src/AbstractRequest.php @@ -124,6 +124,9 @@ public function __construct( $this->linker = $linker; } + /** + * @psalm-suppress UnevaluatedCode + */ public function __toString(): string { try { @@ -133,6 +136,7 @@ public function __toString(): string } catch (Throwable $e) { trigger_error($e->getMessage() . PHP_EOL . $e->getTraceAsString(), E_USER_ERROR); + /** @noinspection PhpUnreachableStatementInspection */ return ''; } } diff --git a/src/JsonSchema/Interceptor/JsonSchemaInterceptor.php b/src/JsonSchema/Interceptor/JsonSchemaInterceptor.php index 37ace58d..2388f710 100644 --- a/src/JsonSchema/Interceptor/JsonSchemaInterceptor.php +++ b/src/JsonSchema/Interceptor/JsonSchemaInterceptor.php @@ -104,7 +104,7 @@ private function validateResponse(ResourceObject $ro, JsonSchema $jsonSchema): v private function validateRo(ResourceObject $ro, string $schemaFile, JsonSchema $jsonSchema): void { /** @var array|false|stdClass $json */ - $json = json_decode(json_encode($ro)); + $json = json_decode((string) json_encode($ro)); /** @var array|stdClass $target */ $target = is_object($json) ? $this->getTarget($json, $jsonSchema) : $json; $this->validate($target, $schemaFile); diff --git a/tests/Module/JsonSchemaFakeModuleTest.php b/tests/Module/JsonSchemaFakeModuleTest.php index b9828051..e24f216a 100644 --- a/tests/Module/JsonSchemaFakeModuleTest.php +++ b/tests/Module/JsonSchemaFakeModuleTest.php @@ -82,6 +82,9 @@ public function linkHeaderTest(): void $this->assertSame('; rel="describedby"', $ro->headers['Link']); } + /** + * @param class-string $class + */ private function getRo(string $class): ResourceObject { $module = $this->getJsonSchemaModule(); @@ -91,6 +94,9 @@ private function getRo(string $class): ResourceObject return $ro; } + /** + * @param class-string $class + */ private function getLinkHeaderRo(string $class): FakeUser { $jsonSchemaHost = 'http://example.com/schema/'; diff --git a/tests/Module/JsonSchemaModuleTest.php b/tests/Module/JsonSchemaModuleTest.php index b9f36c8b..611921c6 100644 --- a/tests/Module/JsonSchemaModuleTest.php +++ b/tests/Module/JsonSchemaModuleTest.php @@ -106,6 +106,9 @@ public function linkHeaderTest(): void $this->assertSame('; rel="describedby"', $ro->headers['Link']); } + /** + * @param class-string $class + */ private function createJsonSchemaException(string $class): JsonSchemaException { $ro = $this->getRo($class); @@ -119,6 +122,9 @@ private function createJsonSchemaException(string $class): JsonSchemaException throw new LogicException(); } + /** + * @param class-string $class + */ private function getRo(string $class): ResourceObject { $module = $this->getJsonSchemaModule(); @@ -129,6 +135,9 @@ private function getRo(string $class): ResourceObject return $ro; } + /** + * @param class-string $class + */ private function getLinkHeaderRo(string $class): ResourceObject { $jsonSchemaHost = 'http://example.com/schema/'; diff --git a/tests/ResourceTest.php b/tests/ResourceTest.php index 9fd3956b..7cc5cf91 100644 --- a/tests/ResourceTest.php +++ b/tests/ResourceTest.php @@ -18,6 +18,8 @@ use Ray\ServiceLocator\ServiceLocator; use function assert; +use function serialize; +use function unserialize; class ResourceTest extends TestCase { @@ -325,4 +327,9 @@ public function testOptions(): void $this->assertInstanceOf(ResourceObject::class, $ro); $this->assertSame('GET, POST, PUT, PATCH, DELETE', $ro->headers['Allow']); } + + public function testSerialize(): void + { + $this->assertInstanceOf(ResourceInterface::class, unserialize(serialize($this->resource))); + } } diff --git a/vendor-bin/tools/composer.lock b/vendor-bin/tools/composer.lock index 52ddd020..be5b0004 100644 --- a/vendor-bin/tools/composer.lock +++ b/vendor-bin/tools/composer.lock @@ -2078,20 +2078,20 @@ }, { "name": "psr/container", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", "shasum": "" }, "require": { - "php": ">=7.2.0" + "php": ">=7.4.0" }, "type": "library", "autoload": { @@ -2120,36 +2120,36 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.1" + "source": "https://github.com/php-fig/container/tree/1.1.2" }, - "time": "2021-03-05T17:36:06+00:00" + "time": "2021-11-05T16:50:12+00:00" }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2170,9 +2170,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:46:02+00:00" }, { "name": "sebastian/cli-parser", @@ -2603,16 +2603,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65" + "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65", - "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", "shasum": "" }, "require": { @@ -2661,14 +2661,14 @@ } ], "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", + "homepage": "https://www.github.com/sebastianbergmann/exporter", "keywords": [ "export", "exporter" ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" }, "funding": [ { @@ -2676,7 +2676,7 @@ "type": "github" } ], - "time": "2020-09-28T05:24:23+00:00" + "time": "2021-11-11T14:18:36+00:00" }, { "name": "sebastian/global-state", @@ -3336,16 +3336,16 @@ }, { "name": "symfony/console", - "version": "v5.3.10", + "version": "v5.3.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3" + "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3", - "reference": "d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3", + "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1", + "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1", "shasum": "" }, "require": { @@ -3353,12 +3353,11 @@ "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1|^2", "symfony/string": "^5.1" }, "conflict": { - "psr/log": ">=3", "symfony/dependency-injection": "<4.4", "symfony/dotenv": "<5.1", "symfony/event-dispatcher": "<4.4", @@ -3366,10 +3365,10 @@ "symfony/process": "<4.4" }, "provide": { - "psr/log-implementation": "1.0|2.0" + "psr/log-implementation": "1.0" }, "require-dev": { - "psr/log": "^1|^2", + "psr/log": "~1.0", "symfony/config": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/event-dispatcher": "^4.4|^5.0", @@ -3415,7 +3414,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.10" + "source": "https://github.com/symfony/console/tree/v5.3.2" }, "funding": [ { @@ -3431,7 +3430,7 @@ "type": "tidelift" } ], - "time": "2021-10-26T09:30:15+00:00" + "time": "2021-06-12T09:42:48+00:00" }, { "name": "symfony/dependency-injection", @@ -4430,16 +4429,16 @@ }, { "name": "vimeo/psalm", - "version": "4.11.2", + "version": "4.12.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "6fba5eb554f9507b72932f9c75533d8af593688d" + "reference": "e42bc4a23f67acba28a23bb09c348e2ff38a1d87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/6fba5eb554f9507b72932f9c75533d8af593688d", - "reference": "6fba5eb554f9507b72932f9c75533d8af593688d", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/e42bc4a23f67acba28a23bb09c348e2ff38a1d87", + "reference": "e42bc4a23f67acba28a23bb09c348e2ff38a1d87", "shasum": "" }, "require": { @@ -4463,7 +4462,7 @@ "openlss/lib-array2xml": "^1.0", "php": "^7.1|^8", "sebastian/diff": "^3.0 || ^4.0", - "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0 || ^6.0", "webmozart/path-util": "^2.3" }, "provide": { @@ -4481,7 +4480,7 @@ "psalm/plugin-phpunit": "^0.16", "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.5", - "symfony/process": "^4.3 || ^5.0", + "symfony/process": "^4.3 || ^5.0 || ^6.0", "weirdan/prophecy-shim": "^1.0 || ^2.0" }, "suggest": { @@ -4529,9 +4528,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.11.2" + "source": "https://github.com/vimeo/psalm/tree/4.12.0" }, - "time": "2021-10-26T17:28:17+00:00" + "time": "2021-11-06T10:31:17+00:00" }, { "name": "webmozart/assert", @@ -4639,6 +4638,7 @@ "issues": "https://github.com/webmozart/path-util/issues", "source": "https://github.com/webmozart/path-util/tree/2.3.0" }, + "abandoned": "symfony/filesystem", "time": "2015-12-17T08:42:14+00:00" } ],