From bafab44bfc1b58b4d70d07a564eaf936351aa0af Mon Sep 17 00:00:00 2001 From: mmasiukevich Date: Fri, 3 Dec 2021 22:31:39 +0100 Subject: [PATCH] update amphp version to 2.6 & update dependencies --- .github/workflows/continuous-integration.yml | 2 +- composer.json | 8 ++++---- phpstan.neon | 16 ++++------------ psalm.xml | 2 +- src/Channel.php | 8 +++----- src/Client.php | 7 +++---- src/Connection.php | 3 --- src/Properties.php | 8 ++++---- 8 files changed, 20 insertions(+), 34 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 91af9b8..766b643 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -41,7 +41,7 @@ jobs: run: composer install -ov - name: Run phpstan/phpstan - run: ./vendor/bin/phpstan analyse src --level 7 + run: ./vendor/bin/phpstan analyse src --level 9 phpunit: name: PHPUnit diff --git a/composer.json b/composer.json index 622e8fa..f741f44 100644 --- a/composer.json +++ b/composer.json @@ -19,14 +19,14 @@ ], "require": { "php": ">=8.0", - "amphp/amp": "v2.5.*", + "amphp/amp": "v2.6.*", "amphp/socket": "v1.1.*", "phpinnacle/buffer": "v1.2.*" }, "require-dev": { "phpunit/phpunit": "v9.5.*", - "vimeo/psalm": "v4.3.*", - "phpstan/phpstan": "v0.12.*" + "vimeo/psalm": "v4.13.*", + "phpstan/phpstan": "v1.2.*" }, "prefer-stable": true, "autoload": { @@ -41,7 +41,7 @@ }, "scripts": { "psalm": "./vendor/bin/psalm --config=psalm.xml", - "phpstan": "./vendor/bin/phpstan analyse src --level 7", + "phpstan": "./vendor/bin/phpstan analyse src --level 9", "tests": "./vendor/bin/phpunit --configuration phpunit.xml --verbose", "coverage": "./vendor/bin/phpunit --configuration phpunit.xml --coverage-html ./coverage --verbose" }, diff --git a/phpstan.neon b/phpstan.neon index 0d1e496..f101b01 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,13 +1,5 @@ parameters: - checkGenericClassInNonGenericObjectType: false - checkMissingIterableValueType: false - ignoreErrors: - - - message: '#Unable to resolve the template type#' - path: %currentWorkingDirectory%/src - - - message: '#AbstractFrame given#' - path: %currentWorkingDirectory%/src/Channel.php - - - message: '#AbstractFrame given#' - path: %currentWorkingDirectory%/src/Client.php \ No newline at end of file + checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false + ignoreErrors: + - '#Cannot cast mixed to int#' diff --git a/psalm.xml b/psalm.xml index d30e53e..5b1a8f1 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,7 +3,6 @@ totallyTyped="true" useDocblockTypes="true" useDocblockPropertyTypes="true" - allowPhpStormGenerics="true" strictBinaryOperands="true" findUnusedPsalmSuppress="true" ignoreInternalFunctionFalseReturn="false" @@ -21,5 +20,6 @@ + diff --git a/src/Channel.php b/src/Channel.php index 3077116..8689fca 100644 --- a/src/Channel.php +++ b/src/Channel.php @@ -1108,6 +1108,7 @@ public function doPublish $buffer->appendUint8(206); if (!empty($body)) { + /* @phpstan-ignore-next-line */ $chunks = \str_split($body, $this->properties->maxFrame()); if ($chunks !== false) { @@ -1126,23 +1127,20 @@ public function doPublish } /** - * @template T + * @template T of Protocol\AbstractFrame * @psalm-param class-string $frame * @psalm-return Promise - * - * @return Promise */ private function await(string $frame): Promise { /** @psalm-var Deferred $deferred */ $deferred = new Deferred; - /** @psalm-var class-string $frame */ - $this->connection->subscribe( $this->id, $frame, static function (Protocol\AbstractFrame $frame) use ($deferred) { + /** @psalm-var T $frame */ $deferred->resolve($frame); return true; diff --git a/src/Client.php b/src/Client.php index 9d135de..def272e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -158,7 +158,7 @@ function () use ($code, $reason) { if ($code === 0) { $promises = []; - foreach ($this->channels as $id => $channel) { + foreach ($this->channels as $channel) { $promises[] = $channel->close($code, $reason); } @@ -400,7 +400,7 @@ private function findChannelId(): int } /** - * @template T + * @template T of Protocol\AbstractFrame * @psalm-param class-string $frame * @psalm-return Promise */ @@ -409,12 +409,11 @@ private function await(string $frame, int $channel = 0): Promise /** @psalm-var Deferred $deferred */ $deferred = new Deferred; - /** @psalm-var class-string $frame */ - $this->connection->subscribe( $channel, $frame, static function (Protocol\AbstractFrame $frame) use ($deferred) { + /** @psalm-var T $frame */ $deferred->resolve($frame); return true; diff --git a/src/Connection.php b/src/Connection.php index 7b4b3a1..958e495 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -137,12 +137,9 @@ function () { $this->parser->append($chunk); while ($frame = $this->parser->parse()) { - /** @var AbstractFrame $frame */ - $class = \get_class($frame); /** - * @psalm-var int $i * @psalm-var callable(AbstractFrame):Promise $callback */ foreach ($this->callbacks[(int)$frame->channel][$class] ?? [] as $i => $callback) { diff --git a/src/Properties.php b/src/Properties.php index 344b711..3ba35db 100644 --- a/src/Properties.php +++ b/src/Properties.php @@ -71,10 +71,10 @@ public function __construct(string $platform, string $product, string $version, /** * @psalm-param array{ - * platform: string, - * product: string, - * version: string, - * capabilities: array + * platform: string|null, + * product: string|null, + * version: string|null, + * capabilities: array|null * } $config */ public static function create(array $config): self