Skip to content

Commit c6072f3

Browse files
committed
Change the order of arguments headers and body
1 parent 5e5530b commit c6072f3

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ composer require httpsoft/http-request
2828
use HttpSoft\Request\Request;
2929
use HttpSoft\Request\RequestFactory;
3030

31-
$request = new Request('POST', 'http://example.com', 'data://,Content', ['Content-Type' => 'text/html'], '2');
31+
$request = new Request('POST', 'http://example.com', ['Content-Type' => 'text/html'], 'data://,Content', '2');
3232
// Or using the factory:
3333
$request = RequestFactory::create(
3434
'POST', // Request method
3535
'https://example.com', // Request URI
36-
'data://,Content', // HTTP message body
3736
['Content-Type' => 'text/html' /* Other headers */],
37+
'data://,Content', // HTTP message body
3838
'2' // HTTP protocol version
3939
);
4040

@@ -59,8 +59,8 @@ $request = new ServerRequest(
5959
$_POST,
6060
'GET', // Request method
6161
'https://example.com', // Request URI
62-
'php://input', // HTTP message body
6362
[/* Headers */],
63+
'php://input', // HTTP message body
6464
'2' // HTTP protocol version
6565
);
6666
// Or using the factory (all necessary data will be received automatically):

src/Request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ final class Request implements RequestInterface, RequestMethodInterface
1515
/**
1616
* @param string $method
1717
* @param UriInterface|string $uri
18-
* @param StreamInterface|string|resource $body
1918
* @param array $headers
19+
* @param StreamInterface|string|resource $body
2020
* @param string $protocol
2121
*/
2222
public function __construct(
2323
string $method = self::METHOD_GET,
2424
$uri = '',
25-
$body = 'php://temp',
2625
array $headers = [],
26+
$body = 'php://temp',
2727
string $protocol = '1.1'
2828
) {
29-
$this->init($method, $uri, $body, $headers, $protocol);
29+
$this->init($method, $uri, $headers, $body, $protocol);
3030
}
3131
}

src/RequestFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ final class RequestFactory implements RequestFactoryInterface
1414
/**
1515
* @param string $method
1616
* @param UriInterface|string $uri
17-
* @param StreamInterface|string|resource $body
1817
* @param array $headers
18+
* @param StreamInterface|string|resource $body
1919
* @param string $protocol
2020
* @return RequestInterface
2121
*/
2222
public static function create(
2323
string $method,
2424
$uri,
25-
$body = 'php://temp',
2625
array $headers = [],
26+
$body = 'php://temp',
2727
string $protocol = '1.1'
2828
): RequestInterface {
29-
return new Request($method, $uri, $body, $headers, $protocol);
29+
return new Request($method, $uri, $headers, $body, $protocol);
3030
}
3131

3232
/**

src/RequestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ public function withUri(UriInterface $uri, $preserveHost = false): RequestInterf
218218
/**
219219
* @param string $method
220220
* @param UriInterface|string $uri
221-
* @param StreamInterface|string|resource $body
222221
* @param array $headers
222+
* @param StreamInterface|string|resource $body
223223
* @param string $protocol
224224
*/
225225
private function init(
226226
string $method = RequestMethodInterface::METHOD_GET,
227227
$uri = '',
228-
$body = 'php://temp',
229228
array $headers = [],
229+
$body = 'php://temp',
230230
string $protocol = '1.1'
231231
): void {
232232
$this->setMethod($method);

src/ServerRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ final class ServerRequest implements ServerRequestInterface, RequestMethodInterf
5959
* @param array|object|null $parsedBody
6060
* @param string $method
6161
* @param UriInterface|string $uri
62-
* @param StreamInterface|string|resource $body
6362
* @param array $headers
63+
* @param StreamInterface|string|resource $body
6464
* @param string $protocol
6565
*/
6666
public function __construct(
@@ -71,8 +71,8 @@ public function __construct(
7171
$parsedBody = null,
7272
string $method = self::METHOD_GET,
7373
$uri = '',
74-
$body = 'php://input',
7574
array $headers = [],
75+
$body = 'php://input',
7676
string $protocol = '1.1'
7777
) {
7878
$this->validateUploadedFiles($uploadedFiles);
@@ -81,7 +81,7 @@ public function __construct(
8181
$this->cookieParams = $cookieParams;
8282
$this->queryParams = $queryParams;
8383
$this->parsedBody = $parsedBody;
84-
$this->init($method, $uri, $body, $headers, $protocol);
84+
$this->init($method, $uri, $headers, $body, $protocol);
8585
}
8686

8787
/**

src/ServerRequestFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public static function createFromGlobals(
4848
$post ?? $_POST,
4949
$normalizer->normalizeMethod($server),
5050
$normalizer->normalizeUri($server),
51-
new StreamPhpInput(),
5251
$normalizer->normalizeHeaders($server),
52+
new StreamPhpInput(),
5353
$normalizer->normalizeProtocolVersion($server)
5454
);
5555
}
@@ -59,6 +59,6 @@ public static function createFromGlobals(
5959
*/
6060
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
6161
{
62-
return new ServerRequest($serverParams, [], [], [], null, $method, $uri, 'php://temp');
62+
return new ServerRequest($serverParams, [], [], [], null, $method, $uri, [], 'php://temp');
6363
}
6464
}

tests/RequestFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function testCreate(): void
2828
$request = RequestFactory::create(
2929
$method = 'POST',
3030
$uri = 'http://example.com',
31-
'data://,Content',
3231
['Content-Type' => 'text/html'],
32+
'data://,Content',
3333
$protocol = '1.0'
3434
);
3535
$this->assertSame($method, $request->getMethod());

0 commit comments

Comments
 (0)