Skip to content

Commit 529f962

Browse files
butschsterroxblnfk
authored andcommitted
Cleanup
1 parent 28e6fcd commit 529f962

File tree

11 files changed

+23
-108
lines changed

11 files changed

+23
-108
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: roadrunner-server

.github/workflows/phpunit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
on:
2+
pull_request: null
23
push:
34
branches:
45
- master
56
- '*.*'
6-
pull_request: null
77

88
name: phpunit
99

@@ -16,4 +16,4 @@ jobs:
1616
php: >-
1717
['8.1', '8.2']
1818
stability: >-
19-
['prefer-stable', 'prefer-lowest']
19+
['prefer-lowest', 'prefer-stable']

.github/workflows/psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
on:
2+
pull_request: null
23
push:
34
branches:
45
- master
56
- '*.*'
6-
pull_request: null
77

88
name: static analysis
99

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ clover*
1515
cover*
1616
.DS_Store
1717
*.cache
18+
19+
.phpunit.cache/
20+
.phpunit.result.cache

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": "MIT",
66
"authors": [
77
{
8-
"name": "Anton Titov (Wolfy-J)",
9-
"email": "wolfy.jd@gmail.com"
8+
"name": "Anton Titov (wolfy-j)",
9+
"email": "wolfy-j@spiralscout.com"
1010
},
1111
{
1212
"name": "Valery Piashchynski",
@@ -45,9 +45,9 @@
4545
"spiral/roadrunner-worker": "^3.0"
4646
},
4747
"require-dev": {
48+
"jetbrains/phpstorm-attributes": "^1.0",
4849
"nyholm/psr7": "^1.3",
4950
"phpunit/phpunit": "^10.0",
50-
"jetbrains/phpstorm-attributes": "^1.0",
5151
"symfony/process": "^6.2",
5252
"vimeo/psalm": "^5.9"
5353
},

src/HttpWorker.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php
22

3-
/**
4-
* This file is part of RoadRunner package.
5-
*
6-
* For the full copyright and license information, please view the LICENSE
7-
* file that was distributed with this source code.
8-
*/
9-
103
declare(strict_types=1);
114

125
namespace Spiral\RoadRunner\Http;
@@ -77,7 +70,7 @@ public function respond(int $status, string|Generator $body, array $headers = []
7770
return;
7871
}
7972

80-
$head = (string)\json_encode([
73+
$head = \json_encode([
8174
'status' => $status,
8275
'headers' => $headers ?: (object)[],
8376
], \JSON_THROW_ON_ERROR);
@@ -87,7 +80,7 @@ public function respond(int $status, string|Generator $body, array $headers = []
8780

8881
private function respondStream(int $status, Generator $body, array $headers = []): void
8982
{
90-
$head = (string)\json_encode([
83+
$head = \json_encode([
9184
'status' => $status,
9285
'headers' => $headers ?: (object)[],
9386
], \JSON_THROW_ON_ERROR);
@@ -124,11 +117,11 @@ private function createRequest(string $body, array $context): Request
124117
cookies: (array)($context['cookies'] ?? []),
125118
uploads: (array)($context['uploads'] ?? []),
126119
attributes: [
127-
Request::PARSED_BODY_ATTRIBUTE_NAME => (bool)$context['parsed'],
120+
Request::PARSED_BODY_ATTRIBUTE_NAME => $context['parsed'],
128121
] + (array)($context['attributes'] ?? []),
129122
query: $query,
130123
body: $body,
131-
parsed: (bool)$context['parsed'],
124+
parsed: $context['parsed'],
132125
);
133126
}
134127

src/HttpWorkerInterface.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php
22

3-
/**
4-
* This file is part of RoadRunner package.
5-
*
6-
* For the full copyright and license information, please view the LICENSE
7-
* file that was distributed with this source code.
8-
*/
9-
103
declare(strict_types=1);
114

125
namespace Spiral\RoadRunner\Http;
@@ -22,8 +15,6 @@ interface HttpWorkerInterface extends WorkerAwareInterface
2215
{
2316
/**
2417
* Wait for incoming http request.
25-
*
26-
* @return Request|null
2718
*/
2819
public function waitRequest(): ?Request;
2920

src/PSR7Worker.php

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php
22

3-
/**
4-
* This file is part of RoadRunner package.
5-
*
6-
* For the full copyright and license information, please view the LICENSE
7-
* file that was distributed with this source code.
8-
*/
9-
103
declare(strict_types=1);
114

125
namespace Spiral\RoadRunner\Http;
@@ -37,65 +30,31 @@ class PSR7Worker implements PSR7WorkerInterface
3730
*/
3831
public int $chunkSize = 0;
3932

40-
/**
41-
* @var HttpWorker
42-
*/
43-
private HttpWorker $httpWorker;
44-
45-
/**
46-
* @var ServerRequestFactoryInterface
47-
*/
48-
private ServerRequestFactoryInterface $requestFactory;
49-
50-
/**
51-
* @var StreamFactoryInterface
52-
*/
53-
private StreamFactoryInterface $streamFactory;
54-
55-
/**
56-
* @var UploadedFileFactoryInterface
57-
*/
58-
private UploadedFileFactoryInterface $uploadsFactory;
33+
private readonly HttpWorker $httpWorker;
5934

60-
/**
61-
* @var array
62-
*/
63-
private array $originalServer;
35+
private readonly array $originalServer;
6436

6537
/**
6638
* @var string[] Valid values for HTTP protocol version
6739
*/
6840
private static array $allowedVersions = ['1.0', '1.1', '2'];
6941

70-
/**
71-
* @param WorkerInterface $worker
72-
* @param ServerRequestFactoryInterface $requestFactory
73-
* @param StreamFactoryInterface $streamFactory
74-
* @param UploadedFileFactoryInterface $uploadsFactory
75-
*/
7642
public function __construct(
7743
WorkerInterface $worker,
78-
ServerRequestFactoryInterface $requestFactory,
79-
StreamFactoryInterface $streamFactory,
80-
UploadedFileFactoryInterface $uploadsFactory
44+
private readonly ServerRequestFactoryInterface $requestFactory,
45+
private readonly StreamFactoryInterface $streamFactory,
46+
private readonly UploadedFileFactoryInterface $uploadsFactory,
8147
) {
8248
$this->httpWorker = new HttpWorker($worker);
83-
$this->requestFactory = $requestFactory;
84-
$this->streamFactory = $streamFactory;
85-
$this->uploadsFactory = $uploadsFactory;
8649
$this->originalServer = $_SERVER;
8750
}
8851

89-
/**
90-
* @return WorkerInterface
91-
*/
9252
public function getWorker(): WorkerInterface
9353
{
9454
return $this->httpWorker->getWorker();
9555
}
9656

9757
/**
98-
* @return ServerRequestInterface|null
9958
* @throws \JsonException
10059
*/
10160
public function waitRequest(): ?ServerRequestInterface
@@ -113,7 +72,6 @@ public function waitRequest(): ?ServerRequestInterface
11372
/**
11473
* Send response to the application server.
11574
*
116-
* @param ResponseInterface $response
11775
* @throws \JsonException
11876
*/
11977
public function respond(ResponseInterface $response): void
@@ -158,7 +116,6 @@ private function streamToGenerator(StreamInterface $stream): Generator
158116
* Returns altered copy of _SERVER variable. Sets ip-address,
159117
* request-time and other values.
160118
*
161-
* @param Request $request
162119
* @return non-empty-array<array-key|string, mixed|string>
163120
*/
164121
protected function configureServer(Request $request): array
@@ -173,7 +130,7 @@ protected function configureServer(Request $request): array
173130

174131
$server['HTTP_USER_AGENT'] = '';
175132
foreach ($request->headers as $key => $value) {
176-
$key = \strtoupper(\str_replace('-', '_', (string)$key));
133+
$key = \strtoupper(\str_replace('-', '_', $key));
177134
if (\in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH'])) {
178135
$server[$key] = \implode(', ', $value);
179136
} else {
@@ -184,26 +141,17 @@ protected function configureServer(Request $request): array
184141
return $server;
185142
}
186143

187-
/**
188-
* @return int
189-
*/
190144
protected function timeInt(): int
191145
{
192146
return \time();
193147
}
194148

195-
/**
196-
* @return float
197-
*/
198149
protected function timeFloat(): float
199150
{
200151
return \microtime(true);
201152
}
202153

203154
/**
204-
* @param Request $httpRequest
205-
* @param array $server
206-
* @return ServerRequestInterface
207155
* @throws \JsonException
208156
*/
209157
protected function mapRequest(Request $httpRequest, array $server): ServerRequestInterface
@@ -278,9 +226,6 @@ protected function wrapUploads(array $files): array
278226

279227
/**
280228
* Normalize HTTP protocol version to valid values
281-
*
282-
* @param string $version
283-
* @return string
284229
*/
285230
private static function fetchProtocolVersion(string $version): string
286231
{

src/PSR7WorkerInterface.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php
22

3-
/**
4-
* This file is part of RoadRunner package.
5-
*
6-
* For the full copyright and license information, please view the LICENSE
7-
* file that was distributed with this source code.
8-
*/
9-
103
declare(strict_types=1);
114

125
namespace Spiral\RoadRunner\Http;

src/Request.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php
22

3-
/**
4-
* This file is part of RoadRunner package.
5-
*
6-
* For the full copyright and license information, please view the LICENSE
7-
* file that was distributed with this source code.
8-
*/
9-
103
declare(strict_types=1);
114

125
namespace Spiral\RoadRunner\Http;
@@ -59,16 +52,12 @@ public function __construct(
5952
) {
6053
}
6154

62-
/**
63-
* @return string
64-
*/
6555
public function getRemoteAddr(): string
6656
{
6757
return (string)($this->attributes['ipAddress'] ?? $this->remoteAddr);
6858
}
6959

7060
/**
71-
* @return array|null
7261
* @throws \JsonException
7362
*/
7463
public function getParsedBody(): ?array

0 commit comments

Comments
 (0)