summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/HttpClient.php2
-rw-r--r--src/PSR7Client.php14
-rw-r--r--src/Worker.php4
3 files changed, 11 insertions, 9 deletions
diff --git a/src/HttpClient.php b/src/HttpClient.php
index 42c434a8..4ca152c8 100644
--- a/src/HttpClient.php
+++ b/src/HttpClient.php
@@ -34,7 +34,7 @@ final class HttpClient
* @return mixed[]|null Request information as ['ctx'=>[], 'body'=>string]
* or null if termination request or invalid context.
*/
- public function acceptRequest()
+ public function acceptRequest(): ?array
{
$body = $this->getWorker()->receive($ctx);
if (empty($body) && empty($ctx)) {
diff --git a/src/PSR7Client.php b/src/PSR7Client.php
index 98897890..777dd891 100644
--- a/src/PSR7Client.php
+++ b/src/PSR7Client.php
@@ -10,11 +10,11 @@ declare(strict_types=1);
namespace Spiral\RoadRunner;
use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
+use Psr\Http\Message\UploadedFileInterface;
/**
* Manages PSR-7 request and response.
@@ -69,7 +69,7 @@ class PSR7Client
/**
* @return ServerRequestInterface|null
*/
- public function acceptRequest()
+ public function acceptRequest(): ?ServerRequestInterface
{
$rawRequest = $this->httpClient->acceptRequest();
if ($rawRequest === null) {
@@ -101,11 +101,11 @@ class PSR7Client
}
if ($rawRequest['ctx']['parsed']) {
- $request = $request->withParsedBody(json_decode($rawRequest['body'], true));
- } else {
- if ($rawRequest['body'] !== null) {
- $request = $request->withBody($this->streamFactory->createStream($rawRequest['body']));
- }
+ return $request->withParsedBody(json_decode($rawRequest['body'], true));
+ }
+
+ if ($rawRequest['body'] !== null) {
+ return $request->withBody($this->streamFactory->createStream($rawRequest['body']));
}
return $request;
diff --git a/src/Worker.php b/src/Worker.php
index 3d1888e3..2da16e86 100644
--- a/src/Worker.php
+++ b/src/Worker.php
@@ -11,6 +11,8 @@ namespace Spiral\RoadRunner;
use Spiral\Goridge\Exceptions\GoridgeException;
use Spiral\Goridge\RelayInterface as Relay;
+use Spiral\Goridge\SocketRelay;
+use Spiral\Goridge\StreamRelay;
use Spiral\RoadRunner\Exception\RoadRunnerException;
/**
@@ -28,7 +30,7 @@ class Worker
// Send as response context to request worker termination
public const STOP = '{"stop":true}';
- /** @var Relay */
+ /** @var Relay|StreamRelay|SocketRelay */
private $relay;
/** @var bool */