Skip to content

Commit 0b80607

Browse files
committed
Upgrade HTTPlug from Legacy to Psr17/18 Discovery Factories
1 parent 4a34304 commit 0b80607

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
],
1313
"require": {
1414
"php": "^7.2 || ^8.0",
15-
"psr/http-message": "^1.0",
16-
"php-http/httplug": "^1.1 || ^2.0",
15+
"ext-json": "*",
16+
"php-http/client-common": "^1.9 || ^2.0",
1717
"php-http/discovery": "^1.0",
1818
"psr/http-client-implementation": "^1.0",
19-
"php-http/client-common": "^1.9 || ^2.0",
2019
"php-http/message-factory": "^1.0",
20+
"psr/http-message-implementation": "^1.0",
2121
"composer-runtime-api": "^2.0"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^8.0 || ^9.0",
25-
"guzzlehttp/guzzle": "^7",
26-
"php-http/mock-client": "^1.0",
2724
"friendsofphp/php-cs-fixer": "^3.0",
28-
"phpstan/phpstan": "^1.2"
25+
"php-http/guzzle7-adapter": "^1.0",
26+
"php-http/mock-client": "^1.0",
27+
"phpstan/phpstan": "^1.2",
28+
"phpunit/phpunit": "^8.0 || ^9.0"
2929
},
3030
"autoload": {
3131
"psr-4": { "PrivatePackagist\\ApiClient\\": "src/" }

src/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace PrivatePackagist\ApiClient;
1111

1212
use Http\Client\Common\Plugin;
13-
use Http\Discovery\UriFactoryDiscovery;
13+
use Http\Discovery\Psr17FactoryDiscovery;
1414
use PrivatePackagist\ApiClient\HttpClient\HttpPluginClientBuilder;
1515
use PrivatePackagist\ApiClient\HttpClient\Message\ResponseMediator;
1616
use PrivatePackagist\ApiClient\HttpClient\Plugin\ExceptionThrower;
@@ -31,7 +31,7 @@ public function __construct(HttpPluginClientBuilder $httpClientBuilder = null, $
3131
$privatePackagistUrl = $privatePackagistUrl ? : 'https://packagist.com';
3232
$this->responseMediator = $responseMediator ? : new ResponseMediator();
3333

34-
$builder->addPlugin(new Plugin\AddHostPlugin(UriFactoryDiscovery::find()->createUri($privatePackagistUrl)));
34+
$builder->addPlugin(new Plugin\AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri($privatePackagistUrl)));
3535
$builder->addPlugin(new PathPrepend('/api'));
3636
$builder->addPlugin(new Plugin\RedirectPlugin());
3737
$headers = [

src/HttpClient/HttpPluginClientBuilder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@
1212
use Http\Client\Common\HttpMethodsClient;
1313
use Http\Client\Common\Plugin;
1414
use Http\Client\Common\PluginClient;
15-
use Http\Discovery\HttpClientDiscovery;
16-
use Http\Discovery\MessageFactoryDiscovery;
17-
use Http\Message\RequestFactory;
15+
use Http\Discovery\Psr17FactoryDiscovery;
16+
use Http\Discovery\Psr18ClientDiscovery;
1817
use Psr\Http\Client\ClientInterface;
18+
use Psr\Http\Message\RequestFactoryInterface;
1919

2020
class HttpPluginClientBuilder
2121
{
2222
/** @var ClientInterface */
2323
private $httpClient;
2424
/** @var HttpMethodsClient|null */
2525
private $pluginClient;
26-
/** @var RequestFactory */
26+
/** @var RequestFactoryInterface */
2727
private $requestFactory;
2828
/** @var Plugin[] */
2929
private $plugins = [];
3030

31-
public function __construct(ClientInterface $httpClient = null, RequestFactory $requestFactory = null)
31+
public function __construct(ClientInterface $httpClient = null, RequestFactoryInterface $requestFactory = null)
3232
{
33-
$this->httpClient = $httpClient ?: HttpClientDiscovery::find();
34-
$this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find();
33+
$this->httpClient = $httpClient ?: Psr18ClientDiscovery::find();
34+
$this->requestFactory = $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory();
3535
}
3636

3737
public function addPlugin(Plugin $plugin)

0 commit comments

Comments
 (0)