Skip to content
This repository was archived by the owner on Feb 10, 2023. It is now read-only.

Commit 3ce04b6

Browse files
Alias Symfony clients
1 parent 866036c commit 3ce04b6

File tree

5 files changed

+39
-41
lines changed

5 files changed

+39
-41
lines changed

.github/workflows/unit-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
matrix:
2828
php:
29-
- '7.1'
29+
- '7.2'
3030
- '8.1'
3131
psr7:
3232
- guzzlehttp/psr7
@@ -40,13 +40,13 @@ jobs:
4040
- php: '8.1'
4141
client: php-http/guzzle7-adapter
4242
psr7: guzzlehttp/psr7
43-
- php: '7.1'
43+
- php: '7.2'
4444
client: php-http/guzzle6-adapter
45-
psr7: guzzlehttp/psr7
45+
psr7: guzzlehttp/psr7:^1.9
4646
- php: '8.1'
4747
client: php-http/react-adapter
4848
psr7: nyholm/psr7
49-
- php: '7.1'
49+
- php: '7.2'
5050
client: php-http/react-adapter
5151
psr7: nyholm/psr7
5252
fail-fast: false

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
"psr/http-message-implementation": "*"
1919
},
2020
"require": {
21-
"php": ">=7.1",
21+
"php": ">=7.2",
2222
"composer-plugin-api": "^2.1",
2323
"composer-runtime-api": "^2.1"
2424
},
2525
"require-dev": {
2626
"composer/composer": "^2.1",
2727
"nyholm/psr7": "^1",
28+
"php-http/discovery": "^1",
2829
"php-http/httplug": "^1|^2",
2930
"psr/http-client": "^1",
3031
"psr/http-factory": "^1",
@@ -42,7 +43,7 @@
4243
"laminas/laminas-diactoros": "<2",
4344
"php-http/curl-client": "<2",
4445
"php-http/react-adapter": "<3",
45-
"symfony/http-client": "<4.4"
46+
"symfony/http-client": "<5.4"
4647
},
4748
"config": {
4849
"sort-packages": true

src/Internal/ComposerPlugin.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,20 @@ public function getMissingRequires(InstalledRepositoryInterface $repo, array $re
238238
}
239239
}
240240

241+
if (!isset($allPackages['nyholm/psr7'])) {
242+
foreach ($missingRequires as $dev => $abstractions) {
243+
if (\in_array('nyholm/psr7', $missingRequires[$dev]['psr/http-factory-implementation'] ?? [], true)) {
244+
continue;
245+
}
246+
foreach ($abstractions as $abstraction => $deps) {
247+
if (\in_array('symfony/http-client', $deps, true)) {
248+
$missingRequires[$dev][$abstraction][] = 'php-http/discovery';
249+
continue 2;
250+
}
251+
}
252+
}
253+
}
254+
241255
$missingRequires[1] = array_diff_key($missingRequires[1], $missingRequires[0]);
242256

243257
return $missingRequires;

src/Internal/Symfony/SymfonyHttplugClient.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,21 @@
99

1010
namespace FriendsOfPHP\WellKnownImplementations\Internal\Symfony;
1111

12-
use FriendsOfPHP\WellKnownImplementations\WellKnownPsr17Factory;
13-
use Http\Client\HttpAsyncClient;
14-
use Http\Client\HttpClient;
15-
use Http\Promise\Promise;
16-
use Psr\Http\Message\RequestInterface;
17-
use Psr\Http\Message\ResponseInterface;
1812
use Symfony\Component\HttpClient\HttplugClient;
1913

2014
/**
2115
* @internal
2216
*/
23-
class SymfonyHttplugClient implements HttpClient, HttpAsyncClient
24-
{
25-
private $client;
17+
class_alias(HttplugClient::class, SymfonyHttplugClient::class);
2618

27-
public function __construct()
19+
if (false) {
20+
/**
21+
* @internal
22+
*/
23+
class SymfonyHttplugClient extends HttplugClient
2824
{
29-
$this->client = new HttplugClient(null, new WellKnownPsr17Factory());
30-
}
31-
32-
public function sendRequest(RequestInterface $request): ResponseInterface
33-
{
34-
return $this->client->sendRequest($request);
35-
}
36-
37-
public function sendAsyncRequest(RequestInterface $request): Promise
38-
{
39-
return $this->client->sendAsyncRequest($request);
25+
public function __construct()
26+
{
27+
}
4028
}
4129
}

src/Internal/Symfony/SymfonyPsr18Client.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,21 @@
99

1010
namespace FriendsOfPHP\WellKnownImplementations\Internal\Symfony;
1111

12-
use FriendsOfPHP\WellKnownImplementations\WellKnownPsr17Factory;
13-
use Psr\Http\Client\ClientInterface;
14-
use Psr\Http\Message\RequestInterface;
15-
use Psr\Http\Message\ResponseInterface;
1612
use Symfony\Component\HttpClient\Psr18Client;
1713

1814
/**
1915
* @internal
2016
*/
21-
class SymfonyPsr18Client implements ClientInterface
22-
{
23-
private $client;
17+
class_alias(Psr18Client::class, SymfonyPsr18Client::class);
2418

25-
public function __construct()
19+
if (false) {
20+
/**
21+
* @internal
22+
*/
23+
class SymfonyPsr18Client extends Psr18Client
2624
{
27-
$this->client = new Psr18Client(null, new WellKnownPsr17Factory());
28-
}
29-
30-
public function sendRequest(RequestInterface $request): ResponseInterface
31-
{
32-
return $this->client->sendRequest($request);
25+
public function __construct()
26+
{
27+
}
3328
}
3429
}

0 commit comments

Comments
 (0)