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-
103declare (strict_types=1 );
114
125namespace 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 {
0 commit comments