Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpClient] Revert support for "friendsofphp/well-known-implementations" #49314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2023
Merged
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
1 change: 0 additions & 1 deletion 1 src/Symfony/Component/HttpClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ CHANGELOG
* Make `HttplugClient` implement `Psr\Http\Message\RequestFactoryInterface`, `StreamFactoryInterface` and `UriFactoryInterface`
* Deprecate implementing `Http\Message\RequestFactory`, `StreamFactory` and `UriFactory` on `HttplugClient`
* Add `withOptions()` to `HttplugClient` and `Psr18Client`
* Add support for "friendsofphp/well-known-implementations"

6.1
---
Expand Down
13 changes: 2 additions & 11 deletions 13 src/Symfony/Component/HttpClient/HttplugClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

namespace Symfony\Component\HttpClient;

use FriendsOfPHP\WellKnownImplementations\WellKnownPsr17Factory;
use FriendsOfPHP\WellKnownImplementations\WellKnownPsr7Request;
use FriendsOfPHP\WellKnownImplementations\WellKnownPsr7Uri;
use GuzzleHttp\Promise\Promise as GuzzlePromise;
use GuzzleHttp\Promise\RejectedPromise;
use GuzzleHttp\Promise\Utils;
Expand Down Expand Up @@ -84,12 +81,12 @@ public function __construct(HttpClientInterface $client = null, ResponseFactoryI
$this->promisePool = class_exists(Utils::class) ? new \SplObjectStorage() : null;

if (null === $responseFactory || null === $streamFactory) {
if (!class_exists(Psr17Factory::class) && !class_exists(WellKnownPsr17Factory::class) && !class_exists(Psr17FactoryDiscovery::class)) {
if (!class_exists(Psr17Factory::class) && !class_exists(Psr17FactoryDiscovery::class)) {
throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\HttplugClient" as no PSR-17 factories have been provided. Try running "composer require nyholm/psr7".');
}

try {
$psr17Factory = class_exists(Psr17Factory::class, false) ? new Psr17Factory() : (class_exists(WellKnownPsr17Factory::class, false) ? new WellKnownPsr17Factory() : null);
$psr17Factory = class_exists(Psr17Factory::class, false) ? new Psr17Factory() : null;
$responseFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findResponseFactory();
$streamFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findStreamFactory();
} catch (NotFoundException $e) {
Expand Down Expand Up @@ -170,8 +167,6 @@ public function createRequest($method, $uri, array $headers = [], $body = null,
$request = $this->responseFactory->createRequest($method, $uri);
} elseif (class_exists(Request::class)) {
$request = new Request($method, $uri);
} elseif (class_exists(WellKnownPsr7Request::class)) {
$request = new WellKnownPsr7Request($method, $uri);
} elseif (class_exists(Psr17FactoryDiscovery::class)) {
$request = Psr17FactoryDiscovery::findRequestFactory()->createRequest($method, $uri);
} else {
Expand Down Expand Up @@ -249,10 +244,6 @@ public function createUri($uri = ''): UriInterface
return new Uri($uri);
}

if (class_exists(WellKnownPsr7Uri::class)) {
return new WellKnownPsr7Uri($uri);
}

if (class_exists(Psr17FactoryDiscovery::class)) {
return Psr17FactoryDiscovery::findUrlFactory()->createUri($uri);
}
Expand Down
15 changes: 2 additions & 13 deletions 15 src/Symfony/Component/HttpClient/Psr18Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

namespace Symfony\Component\HttpClient;

use FriendsOfPHP\WellKnownImplementations\WellKnownPsr17Factory;
use FriendsOfPHP\WellKnownImplementations\WellKnownPsr7Request;
use FriendsOfPHP\WellKnownImplementations\WellKnownPsr7Uri;
use Http\Discovery\Exception\NotFoundException;
use Http\Discovery\Psr17FactoryDiscovery;
use Nyholm\Psr7\Factory\Psr17Factory;
Expand Down Expand Up @@ -65,12 +62,12 @@ public function __construct(HttpClientInterface $client = null, ResponseFactoryI
$streamFactory ??= $responseFactory instanceof StreamFactoryInterface ? $responseFactory : null;

if (null === $responseFactory || null === $streamFactory) {
if (!class_exists(Psr17Factory::class) && !class_exists(WellKnownPsr17Factory::class) && !class_exists(Psr17FactoryDiscovery::class)) {
if (!class_exists(Psr17Factory::class) && !class_exists(Psr17FactoryDiscovery::class)) {
throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\Psr18Client" as no PSR-17 factories have been provided. Try running "composer require nyholm/psr7".');
}

try {
$psr17Factory = class_exists(Psr17Factory::class, false) ? new Psr17Factory() : (class_exists(WellKnownPsr17Factory::class, false) ? new WellKnownPsr17Factory() : null);
$psr17Factory = class_exists(Psr17Factory::class, false) ? new Psr17Factory() : null;
$responseFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findResponseFactory();
$streamFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findStreamFactory();
} catch (NotFoundException $e) {
Expand Down Expand Up @@ -149,10 +146,6 @@ public function createRequest(string $method, $uri): RequestInterface
return new Request($method, $uri);
}

if (class_exists(WellKnownPsr7Request::class)) {
return new WellKnownPsr7Request($method, $uri);
}

if (class_exists(Psr17FactoryDiscovery::class)) {
return Psr17FactoryDiscovery::findRequestFactory()->createRequest($method, $uri);
}
Expand Down Expand Up @@ -191,10 +184,6 @@ public function createUri(string $uri = ''): UriInterface
return new Uri($uri);
}

if (class_exists(WellKnownPsr7Uri::class)) {
return new WellKnownPsr7Uri($uri);
}

if (class_exists(Psr17FactoryDiscovery::class)) {
return Psr17FactoryDiscovery::findUrlFactory()->createUri($uri);
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.