diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f24df12..789358f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.1 tools: composer coverage: xdebug diff --git a/composer.json b/composer.json index 590e977..9651aef 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,17 @@ } ], "require": { - "php": "^7.1|^8.0", + "php": "^8.1", "php-http/httplug": "^2.0", "react/http": "^1.0", "react/event-loop": "^1.2", "php-http/discovery": "^1.0", - "phpunit/phpunit": "^9.3.11 || ^7" + "react/async": "^4" }, "require-dev": { "php-http/client-integration-tests": "^3.0", "php-http/message": "^1.0", + "phpunit/phpunit": "^9.5", "nyholm/psr7": "^1.3" }, "provide": { diff --git a/src/Promise.php b/src/Promise.php index ec7d852..c486888 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -7,6 +7,9 @@ use Http\Promise\Promise as HttpPromise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; + +use function React\Async\await; + use React\EventLoop\LoopInterface; use React\Promise\PromiseInterface; use RuntimeException; @@ -114,12 +117,9 @@ public function getState() */ public function wait($unwrap = true) { - $loop = $this->loop; - while (HttpPromise::PENDING === $this->getState()) { - $loop->futureTick(function () use ($loop) { - $loop->stop(); - }); - $loop->run(); + try { + await($this->promise); + } catch (\Throwable) { } if ($unwrap) {