From 98565085c286864b8da2a7f49dd1fa69a25e645a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 22 Jun 2022 08:50:17 +0200 Subject: [PATCH 1/2] Forward compatibility with upcoming Promise v3 --- .github/workflows/ci.yml | 3 +++ composer.json | 14 ++++++++++---- src/ConnectionManagerRepeat.php | 4 ++-- src/Multiple/ConnectionManagerConcurrent.php | 6 ++---- src/Multiple/ConnectionManagerConsecutive.php | 6 +++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38ed72e..7ad8cc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,8 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: composer install - run: vendor/bin/phpunit --coverage-text if: ${{ matrix.php >= 7.3 }} @@ -35,6 +37,7 @@ jobs: PHPUnit-hhvm: name: PHPUnit (HHVM) runs-on: ubuntu-18.04 + if: false # temporarily skipped until https://github.com/azjezz/setup-hhvm/issues/3 is addressed steps: - uses: actions/checkout@v2 - uses: azjezz/setup-hhvm@v1 diff --git a/composer.json b/composer.json index fa62c43..b65d3f5 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,18 @@ }, "require": { "php": ">=5.3", - "react/socket": "^1.9", "react/event-loop": "^1.2", - "react/promise": "^2.1 || ^1.2.1", - "react/promise-timer": "^1.1" + "react/promise": "^3@dev || ^2.1 || ^1.2.1", + "react/promise-timer": "^1.9", + "react/socket": "dev-promise-3 as 1.12.0" }, "require-dev": { "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8" - } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/WyriHaximus-labs/socket" + } + ] } diff --git a/src/ConnectionManagerRepeat.php b/src/ConnectionManagerRepeat.php index 10f3f5a..5151610 100644 --- a/src/ConnectionManagerRepeat.php +++ b/src/ConnectionManagerRepeat.php @@ -6,7 +6,7 @@ use InvalidArgumentException; use Exception; use React\Promise\Promise; -use React\Promise\CancellablePromiseInterface; +use React\Promise\PromiseInterface; class ConnectionManagerRepeat implements ConnectorInterface { @@ -44,7 +44,7 @@ public function connect($uri) $tries = 0; $reject(new \RuntimeException('Cancelled')); - if ($pending instanceof CancellablePromiseInterface) { + if ($pending instanceof PromiseInterface && \method_exists($pending, 'cancel')) { $pending->cancel(); } }); diff --git a/src/Multiple/ConnectionManagerConcurrent.php b/src/Multiple/ConnectionManagerConcurrent.php index c1eb9cf..b6175f8 100644 --- a/src/Multiple/ConnectionManagerConcurrent.php +++ b/src/Multiple/ConnectionManagerConcurrent.php @@ -2,9 +2,8 @@ namespace ConnectionManager\Extra\Multiple; -use ConnectionManager\Extra\Multiple\ConnectionManagerConsecutive; use React\Promise; -use React\Promise\CancellablePromiseInterface; +use React\Promise\PromiseInterface; class ConnectionManagerConcurrent extends ConnectionManagerConsecutive { @@ -12,14 +11,13 @@ public function connect($uri) { $all = array(); foreach ($this->managers as $connector) { - /* @var $connection Connector */ $all []= $connector->connect($uri); } return Promise\any($all)->then(function ($conn) use ($all) { // a connection attempt succeeded // => cancel all pending connection attempts foreach ($all as $promise) { - if ($promise instanceof CancellablePromiseInterface) { + if ($promise instanceof PromiseInterface && \method_exists($promise, 'cancel')) { $promise->cancel(); } diff --git a/src/Multiple/ConnectionManagerConsecutive.php b/src/Multiple/ConnectionManagerConsecutive.php index 1474b85..b3bfd4c 100644 --- a/src/Multiple/ConnectionManagerConsecutive.php +++ b/src/Multiple/ConnectionManagerConsecutive.php @@ -2,10 +2,10 @@ namespace ConnectionManager\Extra\Multiple; -use React\Socket\ConnectorInterface; use React\Promise; +use React\Promise\PromiseInterface; +use React\Socket\ConnectorInterface; use UnderflowException; -use React\Promise\CancellablePromiseInterface; class ConnectionManagerConsecutive implements ConnectorInterface { @@ -54,7 +54,7 @@ public function tryConnection(array $managers, $uri) $managers = array(); $reject(new \RuntimeException('Cancelled')); - if ($pending instanceof CancellablePromiseInterface) { + if ($pending instanceof PromiseInterface && \method_exists($pending, 'cancel')) { $pending->cancel(); } }); From e6bcf6fa91f7d3bafd9f678666a2e9b53cd563e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 22 Jun 2022 08:55:26 +0200 Subject: [PATCH 2/2] Update to stable reactphp/socket v1.12.0 --- .github/workflows/ci.yml | 3 --- composer.json | 12 +++--------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ad8cc2..38ed72e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,8 +26,6 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: composer install - run: vendor/bin/phpunit --coverage-text if: ${{ matrix.php >= 7.3 }} @@ -37,7 +35,6 @@ jobs: PHPUnit-hhvm: name: PHPUnit (HHVM) runs-on: ubuntu-18.04 - if: false # temporarily skipped until https://github.com/azjezz/setup-hhvm/issues/3 is addressed steps: - uses: actions/checkout@v2 - uses: azjezz/setup-hhvm@v1 diff --git a/composer.json b/composer.json index b65d3f5..01075a9 100644 --- a/composer.json +++ b/composer.json @@ -19,17 +19,11 @@ "require": { "php": ">=5.3", "react/event-loop": "^1.2", - "react/promise": "^3@dev || ^2.1 || ^1.2.1", + "react/promise": "^3 || ^2.1 || ^1.2.1", "react/promise-timer": "^1.9", - "react/socket": "dev-promise-3 as 1.12.0" + "react/socket": "^1.12" }, "require-dev": { "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/WyriHaximus-labs/socket" - } - ] + } }