Skip to content

Commit 45dd47c

Browse files
committed
Change the order of arguments headers and body
1 parent 2b900e9 commit 45dd47c

12 files changed

+28
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ $response->getHeaders(); // []
4040
$response->getProtocolVersion(); // '1.1'
4141

4242
// Create with the passed parameters
43-
$response = new Response(404, '', 'php://memory', ['Content-Language' => 'en'], '2');
43+
$response = new Response(404, ['Content-Language' => 'en'], 'php://memory', '2');
4444
$response->getStatusCode(); // 404
4545
$response->getReasonPhrase(); // 'Not Found'
4646
$response->getBody()->getContents(); // ''

src/EmptyResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public function __construct(
2323
string $protocol = '1.1',
2424
string $reasonPhrase = ''
2525
) {
26-
$this->init($code, $reasonPhrase, StreamFactory::create('php://temp', 'r'), $headers, $protocol);
26+
$this->init($code, $reasonPhrase, $headers, StreamFactory::create('php://temp', 'r'), $protocol);
2727
}
2828
}

src/HtmlResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
string $protocol = '1.1',
2626
string $reasonPhrase = ''
2727
) {
28-
$this->init($code, $reasonPhrase, StreamFactory::createFromContent($html), $headers, $protocol);
28+
$this->init($code, $reasonPhrase, $headers, StreamFactory::createFromContent($html), $protocol);
2929
$this->setContentTypeHeaderIfNotExists('text/html; charset=UTF-8');
3030
}
3131
}

src/JsonResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(
5555
int $encodingOptions = self::DEFAULT_OPTIONS
5656
) {
5757
$json = $this->encode($data, $encodingOptions);
58-
$this->init($code, $reasonPhrase, StreamFactory::createFromContent($json), $headers, $protocol);
58+
$this->init($code, $reasonPhrase, $headers, StreamFactory::createFromContent($json), $protocol);
5959
$this->setContentTypeHeaderIfNotExists('application/json; charset=UTF-8');
6060
}
6161

src/RedirectResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function __construct(
2525
string $reasonPhrase = ''
2626
) {
2727
$headers['Location'] = $uri;
28-
$this->init($code, $reasonPhrase, 'php://temp', $headers, $protocol);
28+
$this->init($code, $reasonPhrase, $headers, 'php://temp', $protocol);
2929
}
3030
}

src/Response.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ final class Response implements ResponseInterface, ResponseStatusCodeInterface
1313

1414
/**
1515
* @param int $statusCode
16-
* @param string $reasonPhrase
17-
* @param StreamInterface|string|resource $body
1816
* @param array $headers
17+
* @param StreamInterface|string|resource $body
1918
* @param string $protocol
19+
* @param string $reasonPhrase
2020
*/
2121
public function __construct(
2222
int $statusCode = self::STATUS_OK,
23-
string $reasonPhrase = '',
24-
$body = 'php://temp',
2523
array $headers = [],
26-
string $protocol = '1.1'
24+
$body = 'php://temp',
25+
string $protocol = '1.1',
26+
string $reasonPhrase = ''
2727
) {
28-
$this->init($statusCode, $reasonPhrase, $body, $headers, $protocol);
28+
$this->init($statusCode, $reasonPhrase, $headers, $body, $protocol);
2929
}
3030
}

src/ResponseFactory.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ final class ResponseFactory implements ResponseFactoryInterface
1212
{
1313
/**
1414
* @param int $statusCode
15-
* @param string $reasonPhrase
16-
* @param StreamInterface|string|resource $body
1715
* @param array $headers
16+
* @param StreamInterface|string|resource $body
1817
* @param string $protocol
18+
* @param string $reasonPhrase
1919
* @return ResponseInterface
2020
*/
2121
public static function create(
2222
int $statusCode = Response::STATUS_OK,
23-
string $reasonPhrase = '',
24-
$body = 'php://temp',
2523
array $headers = [],
26-
string $protocol = '1.1'
24+
$body = 'php://temp',
25+
string $protocol = '1.1',
26+
string $reasonPhrase = ''
2727
): ResponseInterface {
28-
return new Response($statusCode, $reasonPhrase, $body, $headers, $protocol);
28+
return new Response($statusCode, $headers, $body, $protocol, $reasonPhrase);
2929
}
3030

3131
/**
3232
* {@inheritDoc}
3333
*/
3434
public function createResponse(int $statusCode = Response::STATUS_OK, string $reasonPhrase = ''): ResponseInterface
3535
{
36-
return new Response($statusCode, $reasonPhrase);
36+
return new Response($statusCode, [], 'php://temp', '1.1', $reasonPhrase);
3737
}
3838
}

src/ResponseTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ public function getReasonPhrase(): string
123123
private function init(
124124
int $statusCode = ResponseStatusCodeInterface::STATUS_OK,
125125
string $reasonPhrase = '',
126-
$body = 'php://temp',
127126
array $headers = [],
127+
$body = 'php://temp',
128128
string $protocol = '1.1'
129129
): void {
130130
$this->setStatus($statusCode, $reasonPhrase);
131-
$this->stream = StreamFactory::create($body);
132131
$this->registerHeaders($headers);
132+
$this->stream = StreamFactory::create($body);
133133
$this->registerProtocolVersion($protocol);
134134
}
135135

src/TextResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
string $protocol = '1.1',
2626
string $reasonPhrase = ''
2727
) {
28-
$this->init($code, $reasonPhrase, StreamFactory::createFromContent($text), $headers, $protocol);
28+
$this->init($code, $reasonPhrase, $headers, StreamFactory::createFromContent($text), $protocol);
2929
$this->setContentTypeHeaderIfNotExists('text/plain; charset=UTF-8');
3030
}
3131
}

src/XmlResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
string $protocol = '1.1',
2626
string $reasonPhrase = ''
2727
) {
28-
$this->init($code, $reasonPhrase, StreamFactory::createFromContent($xml), $headers, $protocol);
28+
$this->init($code, $reasonPhrase, $headers, StreamFactory::createFromContent($xml), $protocol);
2929
$this->setContentTypeHeaderIfNotExists('application/xml; charset=UTF-8');
3030
}
3131
}

0 commit comments

Comments
 (0)