Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
max-parallel: 10
fail-fast: false
matrix:
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']

steps:
- name: Set up PHP
Expand All @@ -25,7 +26,7 @@ jobs:
tools: flex

- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Download dependencies
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
Expand All @@ -48,7 +49,7 @@ jobs:
tools: flex

- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Download dependencies
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable --prefer-lowest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: PHPStan
uses: docker://oskarstark/phpstan-ga
Expand All @@ -26,7 +26,7 @@ jobs:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
Expand All @@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Psalm
uses: docker://vimeo/psalm-github-actions
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"guzzlehttp/guzzle": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0|^9.3",
"phpunit/phpunit": "^8.5 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"php-http/client-integration-tests": "^3.0",
"phpspec/prophecy-phpunit": "^2.0",
"php-http/message-factory": "^1.1"
Expand Down
2 changes: 2 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ public static function createWithConfig(array $config): Client
return new self(self::buildClient($config));
}

#[\Override]
public function sendRequest(RequestInterface $request): ResponseInterface
{
return $this->sendAsyncRequest($request)->wait();
}

#[\Override]
public function sendAsyncRequest(RequestInterface $request)
{
$promise = $this->guzzle->sendAsync($request);
Expand Down
3 changes: 3 additions & 0 deletions src/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ public function __construct(PromiseInterface $promise, RequestInterface $request
});
}

#[\Override]
public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
{
return new static($this->promise->then($onFulfilled, $onRejected), $this->request);
}

#[\Override]
public function getState()
{
return $this->state;
}

#[\Override]
public function wait($unwrap = true)
{
$this->promise->wait(false);
Expand Down
9 changes: 5 additions & 4 deletions tests/PromiseExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ final class PromiseExceptionTest extends TestCase
/**
* @dataProvider exceptionThatIsThrownForGuzzleExceptionProvider
*/
##[DataProvider('exceptionThatIsThrownForGuzzleExceptionProvider')]
public function testExceptionThatIsThrownForGuzzleException(
RequestInterface $request,
$reason,
string $adapterExceptionClass,
string $adapterExceptionClass
): void {
$guzzlePromise = new \GuzzleHttp\Promise\Promise();
$guzzlePromise->reject($reason);
Expand All @@ -36,10 +37,10 @@ public function testExceptionThatIsThrownForGuzzleException(
$promise->wait();
}

public function exceptionThatIsThrownForGuzzleExceptionProvider(): array
public static function exceptionThatIsThrownForGuzzleExceptionProvider(): array
{
$request = $this->getMockBuilder(RequestInterface::class)->getMock();
$response = $this->getMockBuilder(ResponseInterface::class)->getMock();
$request = (new PromiseExceptionTest)->getMockBuilder(RequestInterface::class)->getMock();
$response = (new PromiseExceptionTest)->getMockBuilder(ResponseInterface::class)->getMock();

return [
[$request, new GuzzleExceptions\ConnectException('foo', $request), NetworkException::class],
Expand Down
Loading