Skip to content

Commit e8e5235

Browse files
committed
[BrowserKit] deprecated Response::getStatus() in favor of Response::getStatusCode()
1 parent 33dbf1a commit e8e5235

File tree

7 files changed

+32
-3
lines changed

7 files changed

+32
-3
lines changed

UPGRADE-4.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
UPGRADE FROM 4.2 to 4.3
22
=======================
33

4+
BrowserKit
5+
----------
6+
7+
* Deprecated `Response::getStatus()`, use `Response::getStatusCode()` instead
8+
49
Config
510
------
611

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ UPGRADE FROM 4.x to 5.0
44
BrowserKit
55
----------
66

7+
* Removed `Response::getStatus()`, use `Response::getStatusCode()` instead
78
* The `Client::submit()` method has a new `$serverParameters` argument.
89

910
Cache

src/Symfony/Component/BrowserKit/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.3.0
5+
-----
6+
7+
* Deprecated `Response::getStatus()`, use `Response::getStatusCode()` instead
8+
49
4.2.0
510
-----
611

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function request(string $method, string $uri, array $parameters = array()
409409

410410
$this->cookieJar->updateFromResponse($this->internalResponse, $uri);
411411

412-
$status = $this->internalResponse->getStatus();
412+
$status = $this->internalResponse->getStatusCode();
413413

414414
if ($status >= 300 && $status < 400) {
415415
$this->redirect = $this->internalResponse->getHeader('Location');
@@ -599,7 +599,7 @@ public function followRedirect()
599599

600600
$request = $this->internalRequest;
601601

602-
if (\in_array($this->internalResponse->getStatus(), array(301, 302, 303))) {
602+
if (\in_array($this->internalResponse->getStatusCode(), array(301, 302, 303))) {
603603
$method = 'GET';
604604
$files = array();
605605
$content = null;

src/Symfony/Component/BrowserKit/Response.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,17 @@ public function getContent()
8383
* Gets the response status code.
8484
*
8585
* @return int The response status code
86+
*
87+
* @deprecated since Symfony 4.3, use getStatusCode() instead
8688
*/
8789
public function getStatus()
90+
{
91+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.3, use getStatusCode() instead.', __METHOD__), E_USER_DEPRECATED);
92+
93+
return $this->status;
94+
}
95+
96+
public function getStatusCode(): int
8897
{
8998
return $this->status;
9099
}

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function doRequest($request)
5252
protected function filterResponse($response)
5353
{
5454
if ($response instanceof SpecialResponse) {
55-
return new Response($response->getContent(), $response->getStatus(), $response->getHeaders());
55+
return new Response($response->getContent(), $response->getStatusCode(), $response->getHeaders());
5656
}
5757

5858
return $response;

src/Symfony/Component/BrowserKit/Tests/ResponseTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,21 @@ public function testGetUri()
2222
$this->assertEquals('foo', $response->getContent(), '->getContent() returns the content of the response');
2323
}
2424

25+
/**
26+
* @group legacy
27+
*/
2528
public function testGetStatus()
2629
{
2730
$response = new Response('foo', 304);
2831
$this->assertEquals('304', $response->getStatus(), '->getStatus() returns the status of the response');
2932
}
3033

34+
public function testGetStatusCode()
35+
{
36+
$response = new Response('foo', 304);
37+
$this->assertEquals('304', $response->getStatusCode(), '->getStatusCode() returns the status of the response');
38+
}
39+
3140
public function testGetHeaders()
3241
{
3342
$response = new Response('foo', 200, array('foo' => 'bar'));

0 commit comments

Comments
 (0)
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