From 5f8617da1703279d463215fea503beddde452329 Mon Sep 17 00:00:00 2001 From: Masiukevich Maksim Date: Sat, 13 Feb 2021 21:55:01 +0100 Subject: [PATCH] types correction --- .github/workflows/continuous-integration.yml | 2 +- composer.json | 10 ++++----- src/Sql/AmpPosgreSQL/AmpPostgreSQLAdapter.php | 7 +++---- .../AmpPosgreSQL/AmpPostgreSQLResultSet.php | 21 ++++++++++--------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8b485c4..59ca978 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -100,7 +100,7 @@ jobs: run: composer update --no-ansi --no-interaction --no-progress - name: Run tests with phpunit - run: XDEBUG_MODE=coverage php ./vendor/bin/phpunit --configuration ./phpunit.xml --coverage-clover=coverage.xml + run: XDEBUG_MODE=coverage php ./vendor/bin/phpunit --configuration ./phpunit.xml --debug --coverage-clover=coverage.xml - name: Send code coverage report to Codecov.io uses: codecov/codecov-action@v1 diff --git a/composer.json b/composer.json index 9601c1a..30550fb 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "require-dev": { "php-service-bus/code-style-config": "v1.3.*", "phpunit/phpunit": "v9.5.*", - "vimeo/psalm": "v4.3.*", + "vimeo/psalm": "v4.5.*", "phpstan/phpstan": "v0.12.*", "amphp/amp": "v2.5.*" }, @@ -62,10 +62,10 @@ "scripts": { "psalm": "./vendor/bin/psalm --config=psalm.xml", "phpstan": "./vendor/bin/phpstan analyse src --level 7", - "tests": "./vendor/bin/phpunit --configuration phpunit.xml --verbose", - "coverage": "./vendor/bin/phpunit --configuration phpunit.xml --coverage-html ./coverage --verbose", - "cs-check": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run", - "cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --allow-risky=yes", + "tests": "./vendor/bin/phpunit --configuration phpunit.xml --debug --verbose --debug", + "coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration phpunit.xml --coverage-html ./coverage --debug --verbose --debug", + "cs-check": "./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run", + "cs-fix": "./vendor/bin/php-cs-fixer fix --allow-risky=yes", "pre-commit": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --allow-risky=yes && ./vendor/bin/psalm --config=psalm.xml && ./vendor/bin/phpstan analyse src --level 7 && ./vendor/bin/phpunit --configuration phpunit.xml --verbose" }, "config": { diff --git a/src/Sql/AmpPosgreSQL/AmpPostgreSQLAdapter.php b/src/Sql/AmpPosgreSQL/AmpPostgreSQLAdapter.php index 8e9696f..826a776 100644 --- a/src/Sql/AmpPosgreSQL/AmpPostgreSQLAdapter.php +++ b/src/Sql/AmpPosgreSQL/AmpPostgreSQLAdapter.php @@ -12,10 +12,9 @@ namespace ServiceBus\Storage\Sql\AmpPosgreSQL; -use Amp\Postgres\PgSqlCommandResult; +use Amp\Iterator; use Amp\Postgres\PooledResultSet; -use Amp\Postgres\PqCommandResult; -use Amp\Sql\ResultSet as AmpResultSet; +use Amp\Sql\CommandResult; use function Amp\call; use function Amp\Postgres\pool; use Amp\Coroutine; @@ -81,7 +80,7 @@ function () use ($queryString, $parameters) : \Generator { $this->logger->debug($queryString, $parameters); - /** @var AmpResultSet|PgSqlCommandResult|PooledResultSet|PqCommandResult $resultSet */ + /** @var Iterator|CommandResult|PooledResultSet $resultSet */ $resultSet = yield $this->pool()->execute($queryString, $parameters); return new AmpPostgreSQLResultSet($resultSet); diff --git a/src/Sql/AmpPosgreSQL/AmpPostgreSQLResultSet.php b/src/Sql/AmpPosgreSQL/AmpPostgreSQLResultSet.php index 9d30d1a..309ddfd 100644 --- a/src/Sql/AmpPosgreSQL/AmpPostgreSQLResultSet.php +++ b/src/Sql/AmpPosgreSQL/AmpPostgreSQLResultSet.php @@ -12,12 +12,13 @@ namespace ServiceBus\Storage\Sql\AmpPosgreSQL; +use Amp\Iterator; +use Amp\Sql\CommandResult; use function Amp\call; use Amp\Postgres\PgSqlCommandResult; use Amp\Postgres\PooledResultSet; use Amp\Postgres\PqCommandResult; use Amp\Promise; -use Amp\Sql\ResultSet as AmpResultSet; use Amp\Success; use ServiceBus\Storage\Common\Exceptions\ResultSetIterationFailed; use ServiceBus\Storage\Common\ResultSet; @@ -28,7 +29,7 @@ class AmpPostgreSQLResultSet implements ResultSet { /** - * @var AmpResultSet|PgSqlCommandResult|PooledResultSet|PqCommandResult + * @var Iterator|CommandResult|PooledResultSet */ private $originalResultSet; @@ -38,9 +39,9 @@ class AmpPostgreSQLResultSet implements ResultSet private $advanceCalled = false; /** - * @param AmpResultSet|PgSqlCommandResult|PooledResultSet|PqCommandResult $originalResultSet + * @param Iterator|CommandResult|PooledResultSet $originalResultSet */ - public function __construct(object $originalResultSet) + public function __construct(Iterator|CommandResult|PooledResultSet $originalResultSet) { $this->originalResultSet = $originalResultSet; } @@ -51,7 +52,7 @@ public function advance(): Promise try { - if ($this->originalResultSet instanceof AmpResultSet) + if ($this->originalResultSet instanceof Iterator) { return $this->originalResultSet->advance(); } @@ -70,14 +71,14 @@ public function getCurrent(): ?array { try { - if ( - $this->originalResultSet instanceof PgSqlCommandResult || - $this->originalResultSet instanceof PqCommandResult - ) { + if ($this->originalResultSet instanceof CommandResult) + { return null; } - /** @var array|null $data */ + /** + * @var array|null $data + */ $data = $this->originalResultSet->getCurrent(); return $data;