diff --git a/UPGRADE-7.0.md b/UPGRADE-7.0.md index 4c294b66bffc8..2c4ca331da7ee 100644 --- a/UPGRADE-7.0.md +++ b/UPGRADE-7.0.md @@ -68,6 +68,11 @@ HttpFoundation * Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead * Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI +HttpClient +---------- + + * Remove implementing `Http\Message\RequestFactory` from `HttplugClient` + HttpKernel ---------- diff --git a/src/Symfony/Component/HttpClient/CHANGELOG.md b/src/Symfony/Component/HttpClient/CHANGELOG.md index d24e0c2cc430b..88a5cc4b533b3 100644 --- a/src/Symfony/Component/HttpClient/CHANGELOG.md +++ b/src/Symfony/Component/HttpClient/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.0 +--- + + * Remove implementing `Http\Message\RequestFactory` from `HttplugClient` + 6.4 --- diff --git a/src/Symfony/Component/HttpClient/HttplugClient.php b/src/Symfony/Component/HttpClient/HttplugClient.php index 9179b0ed4007c..392a6e1b0e4c1 100644 --- a/src/Symfony/Component/HttpClient/HttplugClient.php +++ b/src/Symfony/Component/HttpClient/HttplugClient.php @@ -32,7 +32,6 @@ use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Message\UriInterface; use Symfony\Component\HttpClient\Internal\HttplugWaitLoop; -use Symfony\Component\HttpClient\Internal\LegacyHttplugInterface; use Symfony\Component\HttpClient\Response\HttplugPromise; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -57,7 +56,7 @@ * * @author Nicolas Grekas
*/ -final class HttplugClient implements ClientInterface, HttpAsyncClient, RequestFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ResetInterface, LegacyHttplugInterface +final class HttplugClient implements ClientInterface, HttpAsyncClient, RequestFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ResetInterface { private HttpClientInterface $client; private ResponseFactoryInterface $responseFactory; @@ -150,14 +149,10 @@ public function wait(float $maxDuration = null, float $idleTimeout = null): int } /** - * @param string $method * @param UriInterface|string $uri */ - public function createRequest($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1'): RequestInterface + public function createRequest(string $method, $uri = ''): RequestInterface { - if (2 < \func_num_args()) { - trigger_deprecation('symfony/http-client', '6.2', 'Passing more than 2 arguments to "%s()" is deprecated.', __METHOD__); - } if ($this->responseFactory instanceof RequestFactoryInterface) { $request = $this->responseFactory->createRequest($method, $uri); } elseif (class_exists(Psr17FactoryDiscovery::class)) { @@ -168,44 +163,12 @@ public function createRequest($method, $uri, array $headers = [], $body = null, throw new \LogicException(sprintf('You cannot use "%s()" as no PSR-17 factories have been found. Try running "composer require php-http/discovery psr/http-factory-implementation:*".', __METHOD__)); } - $request = $request - ->withProtocolVersion($protocolVersion) - ->withBody($this->createStream($body ?? '')) - ; - - foreach ($headers as $name => $value) { - $request = $request->withAddedHeader($name, $value); - } - return $request; } - /** - * @param string $content - */ - public function createStream($content = ''): StreamInterface + public function createStream(string $content = ''): StreamInterface { - if (!\is_string($content)) { - trigger_deprecation('symfony/http-client', '6.2', 'Passing a "%s" to "%s()" is deprecated, use "createStreamFrom*()" instead.', get_debug_type($content), __METHOD__); - } - - if ($content instanceof StreamInterface) { - return $content; - } - - if (\is_string($content ?? '')) { - $stream = $this->streamFactory->createStream($content ?? ''); - } elseif (\is_resource($content)) { - $stream = $this->streamFactory->createStreamFromResource($content); - } else { - throw new \InvalidArgumentException(sprintf('"%s()" expects string, resource or StreamInterface, "%s" given.', __METHOD__, get_debug_type($content))); - } - - if ($stream->isSeekable()) { - $stream->seek(0); - } - - return $stream; + return $this->streamFactory->createStream($content); } public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface @@ -218,25 +181,14 @@ public function createStreamFromResource($resource): StreamInterface return $this->streamFactory->createStreamFromResource($resource); } - /** - * @param string $uri - */ - public function createUri($uri = ''): UriInterface + public function createUri(string $uri = ''): UriInterface { - if (!\is_string($uri)) { - trigger_deprecation('symfony/http-client', '6.2', 'Passing a "%s" to "%s()" is deprecated, pass a string instead.', get_debug_type($uri), __METHOD__); - } - - if ($uri instanceof UriInterface) { - return $uri; - } - if ($this->responseFactory instanceof UriFactoryInterface) { return $this->responseFactory->createUri($uri); } if (class_exists(Psr17FactoryDiscovery::class)) { - return Psr17FactoryDiscovery::findUrlFactory()->createUri($uri); + return Psr17FactoryDiscovery::findUriFactory()->createUri($uri); } if (class_exists(Uri::class)) { diff --git a/src/Symfony/Component/HttpClient/Internal/LegacyHttplugInterface.php b/src/Symfony/Component/HttpClient/Internal/LegacyHttplugInterface.php deleted file mode 100644 index 44512cb512495..0000000000000 --- a/src/Symfony/Component/HttpClient/Internal/LegacyHttplugInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpClient\Internal; - -use Http\Client\HttpClient; -use Http\Message\RequestFactory; -use Http\Message\StreamFactory; -use Http\Message\UriFactory; - -if (interface_exists(RequestFactory::class)) { - /** - * @internal - * - * @deprecated since Symfony 6.3 - */ - interface LegacyHttplugInterface extends HttpClient, RequestFactory, StreamFactory, UriFactory - { - } -} else { - /** - * @internal - * - * @deprecated since Symfony 6.3 - */ - interface LegacyHttplugInterface extends HttpClient - { - } -} diff --git a/src/Symfony/Component/HttpClient/composer.json b/src/Symfony/Component/HttpClient/composer.json index 31fa946a06a20..6a2e4bc15d11a 100644 --- a/src/Symfony/Component/HttpClient/composer.json +++ b/src/Symfony/Component/HttpClient/composer.json @@ -24,7 +24,6 @@ "require": { "php": ">=8.2", "psr/log": "^1|^2|^3", - "symfony/deprecation-contracts": "^2.5|^3", "symfony/http-client-contracts": "^3", "symfony/service-contracts": "^2.5|^3" },
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: