Skip to content

Commit edddbd2

Browse files
authored
Merge pull request #11 from agdobrynin/development
Update composer packages. Fix Dockerfile.
2 parents 02955d2 + 1e8a5cb commit edddbd2

File tree

8 files changed

+1142
-478
lines changed

8 files changed

+1142
-478
lines changed

composer.lock

Lines changed: 1088 additions & 424 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServerRequestWizard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function fromParams(
6363
array $cookieParams = [],
6464
array $files = [],
6565
array $parsedBody = [],
66-
StreamInterface|string $body = null,
66+
null|StreamInterface|string $body = null,
6767
): ServerRequestInterface {
6868
$requestMethod = $serverParams['REQUEST_METHOD'] ?? 'GET';
6969
$httpProtocol = 1 === preg_match('/(\d\.\d)$/', $serverParams['SERVER_PROTOCOL'] ?? '', $matches)

src/ServerRequestWizardInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function fromParams(
2525
array $cookieParams = [],
2626
array $files = [],
2727
array $parsedBody = [],
28-
StreamInterface|string $body = null,
28+
null|StreamInterface|string $body = null,
2929
): ServerRequestInterface;
3030
}

tests/Feature/HeadersTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@
3333
'HTTP_ORIGIN' => 'http://127.0.0.1:8080',
3434
];
3535

36-
\it('content type convert', function ($server, $expect) {
36+
\it('content type convert', function ($srvArgs, $expect) {
3737
$httpFactory = new HttpFactory();
3838
$sr = (new ServerRequestWizard(
3939
$httpFactory,
4040
$httpFactory,
4141
$httpFactory,
4242
$httpFactory
43-
))->fromParams($server);
43+
))->fromParams($srvArgs);
4444

4545
\expect(\array_intersect_key($sr->getHeaders(), $expect))
4646
->toBe($expect)
4747
;
4848
})
4949
->with([
5050
'content type test' => [
51-
'server' => \array_merge(
51+
\array_merge(
5252
$simpleServerParams,
5353
[
5454
'CONTENT_LENGTH' => '363715',
@@ -57,44 +57,44 @@
5757
'HTTP_CONTENT_TYPE' => 'multipart/form-data; boundary=----WebKitFormBoundaryIRB3O6SZxfL5m4Lt',
5858
]
5959
),
60-
'expect' => [
60+
[
6161
'Content-Length' => ['363715'],
6262
'Content-Type' => ['multipart/form-data; boundary=----WebKitFormBoundaryIRB3O6SZxfL5m4Lt'],
6363
],
6464
],
6565
'headers with numeric' => [
66-
'server' => \array_merge(
66+
\array_merge(
6767
$simpleServerParams,
6868
[
6969
'HTTP_0' => 'zero header',
7070
'HTTP_1234' => 'numeric header',
7171
]
7272
),
73-
'expect' => [
73+
[
7474
'0' => ['zero header'],
7575
'1234' => ['numeric header'],
7676
],
7777
],
7878
'authorization header' => [
79-
'server' => \array_merge(
79+
\array_merge(
8080
$simpleServerParams,
8181
['REDIRECT_HTTP_AUTHORIZATION' => 'auth-token']
8282
),
83-
'expect' => ['Authorization' => ['auth-token']],
83+
['Authorization' => ['auth-token']],
8484
],
8585
'authorization header php_auth_digest' => [
86-
'server' => \array_merge(
86+
\array_merge(
8787
$simpleServerParams,
8888
['PHP_AUTH_DIGEST' => 'value']
8989
),
90-
'expect' => ['Authorization' => ['value']],
90+
['Authorization' => ['value']],
9191
],
9292
'authorization php_auth_user' => [
93-
'server' => \array_merge(
93+
\array_merge(
9494
$simpleServerParams,
9595
['PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => 'pass']
9696
),
97-
'expect' => ['Authorization' => ['Basic '.\base64_encode('admin:pass')]],
97+
['Authorization' => ['Basic '.\base64_encode('admin:pass')]],
9898
],
9999
])
100100
;

tests/Feature/MethodTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@
1717
\expect($sr->getMethod())->toBe($method);
1818
})->with([
1919
'Method get' => [
20-
'server' => [
20+
[
2121
'SERVER_NAME' => '127.0.0.1',
2222
'REQUEST_URI' => '/',
2323
'REQUEST_METHOD' => 'GET',
2424
'PHP_SELF' => '/index.php',
2525
],
26-
'method' => 'GET',
26+
'GET',
2727
],
2828
'Method post' => [
29-
'server' => [
29+
[
3030
'SERVER_NAME' => '127.0.0.1',
3131
'REQUEST_URI' => '/',
3232
'REQUEST_METHOD' => 'POST',
3333
'PHP_SELF' => '/index.php',
3434
],
35-
'method' => 'POST',
35+
'POST',
3636
],
3737
'Method not set' => [
38-
'server' => [],
39-
'method' => 'GET',
38+
[],
39+
'GET',
4040
],
4141
])
4242
->covers(ServerRequestWizard::class)

tests/Feature/ProtocolVersionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
})
1919
->with([
2020
'Not set protocol' => [
21-
'server' => [],
22-
'protocol' => '1.1',
21+
[],
22+
'1.1',
2323
],
2424
'Has version 1.1' => [
25-
'server' => [
25+
[
2626
'DOCUMENT_ROOT' => '/home/slider/tmp',
2727
'REMOTE_ADDR' => '127.0.0.1',
2828
'REMOTE_PORT' => '40792',
@@ -34,10 +34,10 @@
3434
'REQUEST_METHOD' => 'GET',
3535
'SCRIPT_NAME' => '/index.php',
3636
],
37-
'protocol' => '1.1',
37+
'1.1',
3838
],
3939
'Has version 1.0' => [
40-
'server' => [
40+
[
4141
'DOCUMENT_ROOT' => '/home/slider/tmp',
4242
'REMOTE_ADDR' => '127.0.0.1',
4343
'REMOTE_PORT' => '40792',
@@ -49,7 +49,7 @@
4949
'REQUEST_METHOD' => 'GET',
5050
'SCRIPT_NAME' => '/index.php',
5151
],
52-
'protocol' => '1.0',
52+
'1.0',
5353
],
5454
])
5555
->covers(ServerRequestWizard::class)

tests/Feature/UploadedFilesTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,23 +239,23 @@
239239
->throws(InvalidArgumentException::class)
240240
->with([
241241
'one file without tmp_name key' => [
242-
'files' => [
242+
[
243243
'docs' => [
244244
'name' => 'my-document.txt',
245245
'error' => 0,
246246
],
247247
],
248248
],
249249
'one file without error key' => [
250-
'files' => [
250+
[
251251
'docs' => [
252252
'name' => 'my-document.txt',
253253
'tmp_name' => '/aaaa.txt',
254254
],
255255
],
256256
],
257257
'wrong structure of files' => [
258-
'files' => [
258+
[
259259
'my-form' => [
260260
'name' => 'file1.txt',
261261
'tmp_name' => (object) [],
@@ -264,7 +264,7 @@
264264
],
265265
],
266266
'many files without error key' => [
267-
'files' => [
267+
[
268268
'my-form' => [
269269
'name' => [
270270
'details' => [

tests/Feature/UriFromServerTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Psr\Http\Message\ServerRequestInterface;
88

99
\describe('Creating URI from server headers', function () {
10-
\test('header', function (array $server, string $expectUri) {
10+
\test('header', function (array $srvArgs, string $expectUri) {
1111
$exist = $_SERVER;
12-
$_SERVER = $server;
12+
$_SERVER = $srvArgs;
1313

1414
$httpFactory = new HttpFactory();
1515
$sr = (new ServerRequestWizard(
@@ -27,11 +27,11 @@
2727
})
2828
->with([
2929
'empty' => [
30-
'server' => [],
31-
'expectUri' => '',
30+
[],
31+
'',
3232
],
3333
'with QUERY_STRING different REQUEST_URI' => [
34-
'server' => [
34+
[
3535
'SERVER_NAME' => '127.0.0.1',
3636
'SERVER_PORT' => '8080',
3737
'REQUEST_URI' => '/index.php?list=ok',
@@ -40,10 +40,10 @@
4040
'QUERY_STRING' => 'sort=false',
4141
'HTTP_HOST' => 'hello.st:8080',
4242
],
43-
'expect' => 'http://hello.st:8080/index.php?list=ok',
43+
'http://hello.st:8080/index.php?list=ok',
4444
],
4545
'has HTTP_X_FORWARDED_PROTO' => [
46-
'server' => [
46+
[
4747
'HTTP_X_FORWARDED_PROTO' => 'https',
4848
'SERVER_NAME' => '127.0.0.1',
4949
'SERVER_PORT' => '8080',
@@ -52,10 +52,10 @@
5252
'PHP_SELF' => '/index.php',
5353
'QUERY_STRING' => 'list=ok',
5454
],
55-
'expect' => 'https://127.0.0.1:8080/',
55+
'https://127.0.0.1:8080/',
5656
],
5757
'has HTTPS' => [
58-
'server' => [
58+
[
5959
'SERVER_NAME' => '127.0.0.1',
6060
'SERVER_PORT' => '8080',
6161
'REQUEST_URI' => '/',
@@ -64,10 +64,10 @@
6464
'QUERY_STRING' => 'list=ok',
6565
'HTTPS' => 'on',
6666
],
67-
'expect' => 'https://127.0.0.1:8080/',
67+
'https://127.0.0.1:8080/',
6868
],
6969
'has HTTPS off' => [
70-
'server' => [
70+
[
7171
'SERVER_NAME' => '127.0.0.1',
7272
'SERVER_PORT' => '8080',
7373
'REQUEST_URI' => '/',
@@ -76,69 +76,69 @@
7676
'QUERY_STRING' => 'list=ok',
7777
'HTTPS' => '1',
7878
],
79-
'expect' => 'https://127.0.0.1:8080/',
79+
'https://127.0.0.1:8080/',
8080
],
8181
'not has HTTP_HOST' => [
82-
'server' => [
82+
[
8383
'SERVER_NAME' => '127.0.0.1',
8484
'SERVER_PORT' => '8080',
8585
'REQUEST_URI' => '/index.php?list=ok',
8686
'REQUEST_METHOD' => 'GET',
8787
'PHP_SELF' => '/index.php',
8888
'QUERY_STRING' => 'list=ok',
8989
],
90-
'expect' => 'http://127.0.0.1:8080/index.php?list=ok',
90+
'http://127.0.0.1:8080/index.php?list=ok',
9191
],
9292
'without HTTP_HOST and SERVER_NAME' => [
93-
'server' => [
93+
[
9494
'SERVER_PORT' => '8080',
9595
'REQUEST_URI' => '/index.php?list=ok',
9696
'REQUEST_METHOD' => 'GET',
9797
'PHP_SELF' => '/index.php',
9898
'QUERY_STRING' => 'list=ok',
9999
],
100-
'expect' => '',
100+
'',
101101
],
102102
'without HTTP_HOST header but has non standard port SERVER_PORT' => [
103-
'server' => [
103+
[
104104
'SERVER_NAME' => '[::1]',
105105
'SERVER_PORT' => '8080',
106106
'REQUEST_URI' => '/index.php?list=ok',
107107
'REQUEST_METHOD' => 'GET',
108108
'PHP_SELF' => '/index.php',
109109
'QUERY_STRING' => 'list=ok',
110110
],
111-
'expect' => 'http://[::1]:8080/index.php?list=ok',
111+
'http://[::1]:8080/index.php?list=ok',
112112
],
113113
'without REQUEST_URI' => [
114-
'server' => [
114+
[
115115
'SERVER_NAME' => '127.0.0.1',
116116
'SERVER_PORT' => '8080',
117117
'REQUEST_METHOD' => 'GET',
118118
'ORIG_PATH_INFO' => '/index.php',
119119
'QUERY_STRING' => 'list=ok',
120120
'HTTP_HOST' => 'hello.st:8080',
121121
],
122-
'expect' => 'http://hello.st:8080/index.php?list=ok',
122+
'http://hello.st:8080/index.php?list=ok',
123123
],
124124
'without REQUEST_URI and QUERY_STRING is "0"' => [
125-
'server' => [
125+
[
126126
'SERVER_NAME' => '127.0.0.1',
127127
'SERVER_PORT' => '80',
128128
'REQUEST_METHOD' => 'GET',
129129
'ORIG_PATH_INFO' => '/index.php',
130130
'QUERY_STRING' => '0',
131131
],
132-
'expect' => 'http://127.0.0.1/index.php?0',
132+
'http://127.0.0.1/index.php?0',
133133
],
134134
'without REQUEST_URI and ORIG_PATH_INFO but has QUERY_STRING' => [
135-
'server' => [
135+
[
136136
'SERVER_NAME' => '127.0.0.1',
137137
'SERVER_PORT' => '80',
138138
'REQUEST_METHOD' => 'GET',
139139
'QUERY_STRING' => 'list=ok',
140140
],
141-
'expect' => 'http://127.0.0.1/?list=ok',
141+
'http://127.0.0.1/?list=ok',
142142
],
143143
])
144144
;

0 commit comments

Comments
 (0)