diff --git a/UPGRADE-4.3.md b/UPGRADE-4.3.md index d6a7f00203526..4eb383d46710b 100644 --- a/UPGRADE-4.3.md +++ b/UPGRADE-4.3.md @@ -1,6 +1,13 @@ UPGRADE FROM 4.2 to 4.3 ======================= +BrowserKit +---------- + + * Marked `Response` final. + * Deprecated `Response::buildHeader()` + * Deprecated `Response::getStatus()`, use `Response::getStatusCode()` instead + Config ------ diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index cf677c478a5dd..f446a7c15a378 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -4,6 +4,9 @@ UPGRADE FROM 4.x to 5.0 BrowserKit ---------- + * Removed the possibility to extend `Response` by making it final. + * Removed `Response::buildHeader()` + * Removed `Response::getStatus()`, use `Response::getStatusCode()` instead * The `Client::submit()` method has a new `$serverParameters` argument. Cache diff --git a/src/Symfony/Component/BrowserKit/CHANGELOG.md b/src/Symfony/Component/BrowserKit/CHANGELOG.md index 51d8fbf48c1dd..5ff92bb02477c 100644 --- a/src/Symfony/Component/BrowserKit/CHANGELOG.md +++ b/src/Symfony/Component/BrowserKit/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +4.3.0 +----- + + * Marked `Response` final. + * Deprecated `Response::buildHeader()` + * Deprecated `Response::getStatus()`, use `Response::getStatusCode()` instead + 4.2.0 ----- diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index d483dbcb070c0..0d1382a5f08f5 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -409,7 +409,7 @@ public function request(string $method, string $uri, array $parameters = array() $this->cookieJar->updateFromResponse($this->internalResponse, $uri); - $status = $this->internalResponse->getStatus(); + $status = $this->internalResponse->getStatusCode(); if ($status >= 300 && $status < 400) { $this->redirect = $this->internalResponse->getHeader('Location'); @@ -599,7 +599,7 @@ public function followRedirect() $request = $this->internalRequest; - if (\in_array($this->internalResponse->getStatus(), array(301, 302, 303))) { + if (\in_array($this->internalResponse->getStatusCode(), array(301, 302, 303))) { $method = 'GET'; $files = array(); $content = null; diff --git a/src/Symfony/Component/BrowserKit/Response.php b/src/Symfony/Component/BrowserKit/Response.php index 6c50aeee43361..845be10b686cf 100644 --- a/src/Symfony/Component/BrowserKit/Response.php +++ b/src/Symfony/Component/BrowserKit/Response.php @@ -13,11 +13,16 @@ /** * @author Fabien Potencier + * + * @final since Symfony 4.3 */ class Response { + /** @internal */ protected $content; + /** @internal */ protected $status; + /** @internal */ protected $headers; /** @@ -45,10 +50,10 @@ public function __toString() $headers = ''; foreach ($this->headers as $name => $value) { if (\is_string($value)) { - $headers .= $this->buildHeader($name, $value); + $headers .= sprintf("%s: %s\n", $name, $value); } else { foreach ($value as $headerValue) { - $headers .= $this->buildHeader($name, $headerValue); + $headers .= sprintf("%s: %s\n", $name, $headerValue); } } } @@ -63,9 +68,13 @@ public function __toString() * @param string $value The header value * * @return string The built header line + * + * @deprecated since Symfony 4.3 */ protected function buildHeader($name, $value) { + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED); + return sprintf("%s: %s\n", $name, $value); } @@ -83,8 +92,17 @@ public function getContent() * Gets the response status code. * * @return int The response status code + * + * @deprecated since Symfony 4.3, use getStatusCode() instead */ public function getStatus() + { + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.3, use getStatusCode() instead.', __METHOD__), E_USER_DEPRECATED); + + return $this->status; + } + + public function getStatusCode(): int { return $this->status; } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index 1a34c623bcb91..e4cec8b393a38 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -52,7 +52,7 @@ protected function doRequest($request) protected function filterResponse($response) { if ($response instanceof SpecialResponse) { - return new Response($response->getContent(), $response->getStatus(), $response->getHeaders()); + return new Response($response->getContent(), $response->getStatusCode(), $response->getHeaders()); } return $response; diff --git a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php index 0ba4e3b3a71d9..8afebe454cc8b 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php @@ -22,12 +22,21 @@ public function testGetUri() $this->assertEquals('foo', $response->getContent(), '->getContent() returns the content of the response'); } + /** + * @group legacy + */ public function testGetStatus() { $response = new Response('foo', 304); $this->assertEquals('304', $response->getStatus(), '->getStatus() returns the status of the response'); } + public function testGetStatusCode() + { + $response = new Response('foo', 304); + $this->assertEquals('304', $response->getStatusCode(), '->getStatusCode() returns the status of the response'); + } + public function testGetHeaders() { $response = new Response('foo', 200, array('foo' => 'bar')); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy