Skip to content

Commit 3b623a6

Browse files
authored
Merge pull request #16 from php-http/housekeeping
cleanup branch alias and explicitly require legacy message-factory
2 parents 0332804 + b88310d commit 3b623a6

17 files changed

+59
-64
lines changed

.github/workflows/ci.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: Tests
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- '[0-9]+.x'
6+
- '[0-9]+.[0-9]+'
7+
- '[0-9]+.[0-9]+.x'
8+
pull_request:
39

410
jobs:
511
build:
@@ -8,18 +14,18 @@ jobs:
814
strategy:
915
max-parallel: 10
1016
matrix:
11-
php: [ '7.3', '7.4', '8.0', '8.1', '8.2']
17+
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
1218

1319
steps:
1420
- name: Set up PHP
15-
uses: shivammathur/setup-php@2.5.0
21+
uses: shivammathur/setup-php@2.30.0
1622
with:
1723
php-version: ${{ matrix.php }}
1824
coverage: none
1925
tools: flex
2026

2127
- name: Checkout code
22-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2329

2430
- name: Download dependencies
2531
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
@@ -35,14 +41,14 @@ jobs:
3541
runs-on: ubuntu-latest
3642
steps:
3743
- name: Set up PHP
38-
uses: shivammathur/setup-php@2.5.0
44+
uses: shivammathur/setup-php@2.30.0
3945
with:
4046
php-version: 7.3
4147
coverage: none
4248
tools: flex
4349

4450
- name: Checkout code
45-
uses: actions/checkout@v3
51+
uses: actions/checkout@v4
4652

4753
- name: Download dependencies
4854
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable --prefer-lowest

.github/workflows/static.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
on: [push, pull_request]
21
name: Static analysis
2+
on:
3+
push:
4+
branches:
5+
- '[0-9]+.x'
6+
- '[0-9]+.[0-9]+'
7+
- '[0-9]+.[0-9]+.x'
8+
pull_request:
39

410
jobs:
511
phpstan:
612
name: PHPStan
713
runs-on: ubuntu-latest
814
steps:
915
- name: Checkout code
10-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1117

1218
- name: PHPStan
1319
uses: docker://oskarstark/phpstan-ga
@@ -20,7 +26,7 @@ jobs:
2026
name: PHP-CS-Fixer
2127
runs-on: ubuntu-latest
2228
steps:
23-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
2430
- name: PHP-CS-Fixer
2531
uses: docker://oskarstark/php-cs-fixer-ga
2632
with:
@@ -31,7 +37,7 @@ jobs:
3137
runs-on: ubuntu-latest
3238
steps:
3339
- name: Checkout code
34-
uses: actions/checkout@v3
40+
uses: actions/checkout@v4
3541

3642
- name: Psalm
3743
uses: docker://vimeo/psalm-github-actions

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/.php_cs.cache
1+
/.php-cs-fixer.cache
22
/composer.lock
33
/phpunit.xml
44
/vendor/

composer.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"require-dev": {
2020
"phpunit/phpunit": "^8.0|^9.3",
2121
"php-http/client-integration-tests": "^3.0",
22-
"phpspec/prophecy-phpunit": "^2.0"
22+
"phpspec/prophecy-phpunit": "^2.0",
23+
"php-http/message-factory": "^1.1"
2324
},
2425
"provide": {
2526
"php-http/client-implementation": "1.0",
@@ -36,11 +37,6 @@
3637
"Http\\Adapter\\Guzzle7\\Tests\\": "tests/"
3738
}
3839
},
39-
"extra": {
40-
"branch-alias": {
41-
"dev-master": "1.x-dev"
42-
}
43-
},
4440
"scripts": {
4541
"test": "@php vendor/bin/phpunit"
4642
}

psalm.baseline.xml

+5
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@
55
<code>$exception-&gt;getResponse()</code>
66
</PossiblyNullArgument>
77
</file>
8+
<file src="src/Client.php">
9+
<PossiblyUnusedMethod occurrences="1">
10+
<code>createWithConfig</code>
11+
</PossiblyUnusedMethod>
12+
</file>
813
</files>

src/Client.php

-6
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,11 @@ public static function createWithConfig(array $config): Client
4343
return new self(self::buildClient($config));
4444
}
4545

46-
/**
47-
* {@inheritdoc}
48-
*/
4946
public function sendRequest(RequestInterface $request): ResponseInterface
5047
{
5148
return $this->sendAsyncRequest($request)->wait();
5249
}
5350

54-
/**
55-
* {@inheritdoc}
56-
*/
5751
public function sendAsyncRequest(RequestInterface $request)
5852
{
5953
$promise = $this->guzzle->sendAsync($request);

src/Promise.php

+5-14
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ public function __construct(PromiseInterface $promise, RequestInterface $request
5353
$this->state = self::FULFILLED;
5454

5555
return $response;
56-
}, function ($reason) use ($request) {
56+
}, function ($reason) {
5757
$this->state = self::REJECTED;
5858

5959
if ($reason instanceof HttplugException) {
6060
$this->exception = $reason;
6161
} elseif ($reason instanceof GuzzleExceptions\GuzzleException) {
62-
$this->exception = $this->handleException($reason, $request);
62+
$this->exception = $this->handleException($reason);
6363
} elseif ($reason instanceof \Throwable) {
6464
$this->exception = new HttplugException\TransferException('Invalid exception returned from Guzzle7', 0, $reason);
6565
} else {
@@ -70,31 +70,22 @@ public function __construct(PromiseInterface $promise, RequestInterface $request
7070
});
7171
}
7272

73-
/**
74-
* {@inheritdoc}
75-
*/
76-
public function then(callable $onFulfilled = null, callable $onRejected = null)
73+
public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
7774
{
7875
return new static($this->promise->then($onFulfilled, $onRejected), $this->request);
7976
}
8077

81-
/**
82-
* {@inheritdoc}
83-
*/
8478
public function getState()
8579
{
8680
return $this->state;
8781
}
8882

89-
/**
90-
* {@inheritdoc}
91-
*/
9283
public function wait($unwrap = true)
9384
{
9485
$this->promise->wait(false);
9586

9687
if ($unwrap) {
97-
if (self::REJECTED == $this->getState()) {
88+
if (self::REJECTED === $this->getState()) {
9889
throw $this->exception;
9990
}
10091

@@ -107,7 +98,7 @@ public function wait($unwrap = true)
10798
*
10899
* @return HttplugException
109100
*/
110-
private function handleException(GuzzleExceptions\GuzzleException $exception, RequestInterface $request)
101+
private function handleException(GuzzleExceptions\GuzzleException $exception)
111102
{
112103
if ($exception instanceof GuzzleExceptions\ConnectException) {
113104
return new HttplugException\NetworkException($exception->getMessage(), $exception->getRequest(), $exception);

tests/CurlHttpAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class CurlHttpAdapterTest extends HttpAdapterTest
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
protected function createHandler()
1815
{
1916
return new CurlHandler();

tests/CurlHttpAsyncAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class CurlHttpAsyncAdapterTest extends HttpAsyncAdapterTest
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
protected function createHandler()
1815
{
1916
return new CurlHandler();

tests/DefaultHttpAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
class DefaultHttpAdapterTest extends HttpClientTest
1515
{
16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createHttpAdapter(): ClientInterface
2017
{
2118
return new Client();
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Http\Adapter\Guzzle7\Client;
6+
use Http\Client\Tests\HttpClientTest;
7+
use Psr\Http\Client\ClientInterface;
8+
9+
/**
10+
* @author David Buchmann <[email protected]>
11+
*/
12+
class DefaultHttpAdapterWithConfigTest extends HttpClientTest
13+
{
14+
protected function createHttpAdapter(): ClientInterface
15+
{
16+
$this->defaultHeaders['X-Test'] = 'configuration-value';
17+
18+
return Client::createWithConfig([
19+
'headers' => [
20+
'X-Test' => 'configuration-value',
21+
],
22+
]);
23+
}
24+
}

tests/HttpAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
*/
1515
abstract class HttpAdapterTest extends HttpClientTest
1616
{
17-
/**
18-
* {@inheritdoc}
19-
*/
2017
protected function createHttpAdapter(): ClientInterface
2118
{
2219
return new Client(new GuzzleClient(['handler' => $this->createHandler()]));

tests/HttpAsyncAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
*/
1515
abstract class HttpAsyncAdapterTest extends HttpAsyncClientTest
1616
{
17-
/**
18-
* {@inheritdoc}
19-
*/
2017
protected function createHttpAsyncClient(): HttpAsyncClient
2118
{
2219
return new Client(new GuzzleClient(['handler' => $this->createHandler()]));

tests/MultiCurlHttpAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class MultiCurlHttpAdapterTest extends HttpAdapterTest
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
protected function createHandler()
1815
{
1916
return new CurlMultiHandler();

tests/MultiCurlHttpAsyncAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class MultiCurlHttpAsyncAdapterTest extends HttpAsyncAdapterTest
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
protected function createHandler()
1815
{
1916
return new CurlMultiHandler();

tests/StreamHttpAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class StreamHttpAdapterTest extends HttpAdapterTest
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
protected function createHandler()
1815
{
1916
return new StreamHandler();

tests/StreamHttpAsyncAdapterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class StreamHttpAsyncAdapterTest extends HttpAsyncAdapterTest
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
protected function createHandler()
1815
{
1916
return new StreamHandler();

0 commit comments

Comments
 (0)