diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index f7ca8d5..b09b6fc 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\JsonRpc\Listener\RegisterProtocolListener; diff --git a/src/CoreMiddleware.php b/src/CoreMiddleware.php index 22d4b91..1f6a636 100644 --- a/src/CoreMiddleware.php +++ b/src/CoreMiddleware.php @@ -9,11 +9,13 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Closure; use Hyperf\HttpServer\Router\Dispatched; use Hyperf\Rpc\Protocol; +use InvalidArgumentException; use Psr\Container\ContainerInterface; use Psr\Http\Message\ServerRequestInterface; use Swow\Psr7\Message\ResponsePlusInterface; @@ -44,7 +46,7 @@ protected function handleFound(Dispatched $dispatched, ServerRequestInterface $r try { $parameters = $this->parseMethodParameters($controller, $action, $request->getParsedBody()); - } catch (\InvalidArgumentException) { + } catch (InvalidArgumentException) { return $this->responseBuilder->buildErrorResponse($request, ResponseBuilder::INVALID_PARAMS); } diff --git a/src/DataFormatter.php b/src/DataFormatter.php index 513d647..99d421c 100644 --- a/src/DataFormatter.php +++ b/src/DataFormatter.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Rpc\Context; diff --git a/src/DataFormatterFactory.php b/src/DataFormatterFactory.php index 95bbf52..0e208fe 100644 --- a/src/DataFormatterFactory.php +++ b/src/DataFormatterFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Contract\NormalizerInterface; diff --git a/src/Exception/BadRequestException.php b/src/Exception/BadRequestException.php index d35d4b7..dda9e56 100644 --- a/src/Exception/BadRequestException.php +++ b/src/Exception/BadRequestException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Exception; use Hyperf\HttpMessage\Exception\BadRequestHttpException; diff --git a/src/Exception/ClientException.php b/src/Exception/ClientException.php index d0331e4..eeaebf1 100644 --- a/src/Exception/ClientException.php +++ b/src/Exception/ClientException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Exception; use RuntimeException; diff --git a/src/Exception/Handler/HttpExceptionHandler.php b/src/Exception/Handler/HttpExceptionHandler.php index bc4eae6..52ace48 100644 --- a/src/Exception/Handler/HttpExceptionHandler.php +++ b/src/Exception/Handler/HttpExceptionHandler.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Exception\Handler; class HttpExceptionHandler extends TcpExceptionHandler diff --git a/src/Exception/Handler/TcpExceptionHandler.php b/src/Exception/Handler/TcpExceptionHandler.php index 7f26eba..2cc9a00 100644 --- a/src/Exception/Handler/TcpExceptionHandler.php +++ b/src/Exception/Handler/TcpExceptionHandler.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Exception\Handler; use Hyperf\Contract\StdoutLoggerInterface; diff --git a/src/HttpCoreMiddleware.php b/src/HttpCoreMiddleware.php index abedf4d..90f14ea 100644 --- a/src/HttpCoreMiddleware.php +++ b/src/HttpCoreMiddleware.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/HttpServer.php b/src/HttpServer.php index 6265cc7..791f470 100644 --- a/src/HttpServer.php +++ b/src/HttpServer.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Context\RequestContext; diff --git a/src/JsonRpcHttpTransporter.php b/src/JsonRpcHttpTransporter.php index 26e541f..44f4998 100644 --- a/src/JsonRpcHttpTransporter.php +++ b/src/JsonRpcHttpTransporter.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use GuzzleHttp\Client; diff --git a/src/JsonRpcNormalizer.php b/src/JsonRpcNormalizer.php index 52cce52..eca7e46 100644 --- a/src/JsonRpcNormalizer.php +++ b/src/JsonRpcNormalizer.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Contract\NormalizerInterface; diff --git a/src/JsonRpcPoolTransporter.php b/src/JsonRpcPoolTransporter.php index 3c9f6b3..5ef99dc 100644 --- a/src/JsonRpcPoolTransporter.php +++ b/src/JsonRpcPoolTransporter.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Context\ApplicationContext; diff --git a/src/JsonRpcTransporter.php b/src/JsonRpcTransporter.php index 5683df9..1dd9c4a 100644 --- a/src/JsonRpcTransporter.php +++ b/src/JsonRpcTransporter.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Context\ApplicationContext; diff --git a/src/Listener/RegisterProtocolListener.php b/src/Listener/RegisterProtocolListener.php index 6322e93..29340e7 100644 --- a/src/Listener/RegisterProtocolListener.php +++ b/src/Listener/RegisterProtocolListener.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Listener; use Hyperf\Codec\Packer\JsonPacker; diff --git a/src/Listener/RegisterServiceListener.php b/src/Listener/RegisterServiceListener.php index f1a5187..33b701d 100644 --- a/src/Listener/RegisterServiceListener.php +++ b/src/Listener/RegisterServiceListener.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Listener; use Hyperf\Event\Contract\ListenerInterface; diff --git a/src/NormalizeDataFormatter.php b/src/NormalizeDataFormatter.php index 459553f..61838c3 100644 --- a/src/NormalizeDataFormatter.php +++ b/src/NormalizeDataFormatter.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Contract\NormalizerInterface; diff --git a/src/Packer/JsonEofPacker.php b/src/Packer/JsonEofPacker.php index f0fd339..d47dc4a 100644 --- a/src/Packer/JsonEofPacker.php +++ b/src/Packer/JsonEofPacker.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Packer; use Hyperf\Contract\PackerInterface; diff --git a/src/Packer/JsonLengthPacker.php b/src/Packer/JsonLengthPacker.php index 9a23c54..f9a3b3f 100644 --- a/src/Packer/JsonLengthPacker.php +++ b/src/Packer/JsonLengthPacker.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Packer; use Hyperf\Contract\PackerInterface; diff --git a/src/PathGenerator.php b/src/PathGenerator.php index c3cf8c4..1698e4a 100644 --- a/src/PathGenerator.php +++ b/src/PathGenerator.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; class PathGenerator extends \Hyperf\Rpc\PathGenerator\PathGenerator diff --git a/src/Pool/Frequency.php b/src/Pool/Frequency.php index a35e29c..535aff8 100644 --- a/src/Pool/Frequency.php +++ b/src/Pool/Frequency.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Pool; use Hyperf\Pool\Frequency as BaseFrequency; diff --git a/src/Pool/PoolFactory.php b/src/Pool/PoolFactory.php index 5da3fcd..bf09710 100644 --- a/src/Pool/PoolFactory.php +++ b/src/Pool/PoolFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Pool; use Hyperf\Di\Container; diff --git a/src/Pool/RpcConnection.php b/src/Pool/RpcConnection.php index fa48bc6..9fbe491 100644 --- a/src/Pool/RpcConnection.php +++ b/src/Pool/RpcConnection.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Pool; use Closure; @@ -54,17 +55,17 @@ public function __get($name) return $this->connection->{$name}; } - public function send(string $data): int|false + public function send(string $data): false|int { return $this->connection->sendAll($data); } - public function recv(float $timeout = 0): string|false + public function recv(float $timeout = 0): false|string { return $this->recvPacket($timeout); } - public function recvPacket(float $timeout = 0): string|false + public function recvPacket(float $timeout = 0): false|string { return $this->connection->recvPacket($timeout); } diff --git a/src/Pool/RpcPool.php b/src/Pool/RpcPool.php index 9262979..bffcc90 100644 --- a/src/Pool/RpcPool.php +++ b/src/Pool/RpcPool.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc\Pool; use Hyperf\Contract\ConnectionInterface; diff --git a/src/RecvTrait.php b/src/RecvTrait.php index 923a8d5..539e446 100644 --- a/src/RecvTrait.php +++ b/src/RecvTrait.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Engine\Contract\SocketInterface; diff --git a/src/ResponseBuilder.php b/src/ResponseBuilder.php index 1a36e98..2c5815b 100644 --- a/src/ResponseBuilder.php +++ b/src/ResponseBuilder.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Context\Context; diff --git a/src/TcpServer.php b/src/TcpServer.php index 52d4557..25701a0 100644 --- a/src/TcpServer.php +++ b/src/TcpServer.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\JsonRpc; use Hyperf\Context\ResponseContext; @@ -29,6 +30,7 @@ use Hyperf\Server\Exception\InvalidArgumentException; use Hyperf\Server\ServerManager; use Psr\Container\ContainerInterface; +use Swoole\Server\Port; use Swow\Psr7\Message\ResponsePlusInterface; use Swow\Psr7\Message\ServerRequestPlusInterface; @@ -120,7 +122,7 @@ protected function buildJsonRpcRequest(int $fd, int $reactorId, array $data) if (! isset($data['params'])) { $data['params'] = []; } - /** @var \Swoole\Server\Port $port */ + /** @var Port $port */ [, $port] = ServerManager::get($this->serverName); $uri = (new Uri())->setPath($data['method'])->setHost($port->host)->setPort($port->port); diff --git a/tests/AnyParamCoreMiddlewareTest.php b/tests/AnyParamCoreMiddlewareTest.php index 72e4496..4620c74 100644 --- a/tests/AnyParamCoreMiddlewareTest.php +++ b/tests/AnyParamCoreMiddlewareTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use Error; diff --git a/tests/CoreMiddlewareTest.php b/tests/CoreMiddlewareTest.php index 70977b6..f18093e 100644 --- a/tests/CoreMiddlewareTest.php +++ b/tests/CoreMiddlewareTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use Hyperf\Codec\Packer\JsonPacker; diff --git a/tests/DataFormatterTest.php b/tests/DataFormatterTest.php index 1f02e81..4cc3bf2 100644 --- a/tests/DataFormatterTest.php +++ b/tests/DataFormatterTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use Hyperf\JsonRpc\DataFormatter; diff --git a/tests/JsonPackerTest.php b/tests/JsonPackerTest.php index c3cba9b..a4d962c 100644 --- a/tests/JsonPackerTest.php +++ b/tests/JsonPackerTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use Hyperf\JsonRpc\Packer\JsonEofPacker; diff --git a/tests/JsonRpcHttpTransporterTest.php b/tests/JsonRpcHttpTransporterTest.php index 52fdd0a..952febc 100644 --- a/tests/JsonRpcHttpTransporterTest.php +++ b/tests/JsonRpcHttpTransporterTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use GuzzleHttp\Client; diff --git a/tests/JsonRpcPoolTransporterTest.php b/tests/JsonRpcPoolTransporterTest.php index 86f0342..b437fdf 100644 --- a/tests/JsonRpcPoolTransporterTest.php +++ b/tests/JsonRpcPoolTransporterTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use Hyperf\Context\ApplicationContext; diff --git a/tests/RpcServiceClientTest.php b/tests/RpcServiceClientTest.php index f7ced4a..f26a06d 100644 --- a/tests/RpcServiceClientTest.php +++ b/tests/RpcServiceClientTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use Hyperf\Codec\Packer\JsonPacker; diff --git a/tests/Stub/CalculatorProxyServiceClient.php b/tests/Stub/CalculatorProxyServiceClient.php index 3eeee9e..ed0bff8 100644 --- a/tests/Stub/CalculatorProxyServiceClient.php +++ b/tests/Stub/CalculatorProxyServiceClient.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc\Stub; use Hyperf\RpcClient\Proxy\AbstractProxyService; diff --git a/tests/Stub/CalculatorService.php b/tests/Stub/CalculatorService.php index 2096426..37b2967 100644 --- a/tests/Stub/CalculatorService.php +++ b/tests/Stub/CalculatorService.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc\Stub; use Error; diff --git a/tests/Stub/CalculatorServiceInterface.php b/tests/Stub/CalculatorServiceInterface.php index b1d9c2b..ff188c3 100644 --- a/tests/Stub/CalculatorServiceInterface.php +++ b/tests/Stub/CalculatorServiceInterface.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc\Stub; interface CalculatorServiceInterface diff --git a/tests/Stub/IntegerValue.php b/tests/Stub/IntegerValue.php index b43a382..3e773c1 100644 --- a/tests/Stub/IntegerValue.php +++ b/tests/Stub/IntegerValue.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc\Stub; class IntegerValue diff --git a/tests/Stub/RpcConnectionStub.php b/tests/Stub/RpcConnectionStub.php index 0805cfb..f64047c 100644 --- a/tests/Stub/RpcConnectionStub.php +++ b/tests/Stub/RpcConnectionStub.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc\Stub; use Closure; @@ -29,13 +30,13 @@ public function __get($name) // return $this->connection->{$name}; } - public function send(string $data): int|false + public function send(string $data): false|int { $this->lastData = $data; return strlen($data); } - public function recvPacket(float $timeout = 0): string|false + public function recvPacket(float $timeout = 0): false|string { return $this->lastData; } diff --git a/tests/Stub/RpcPoolStub.php b/tests/Stub/RpcPoolStub.php index 74fcf0a..62a48ef 100644 --- a/tests/Stub/RpcPoolStub.php +++ b/tests/Stub/RpcPoolStub.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc\Stub; use Hyperf\Contract\ConnectionInterface; diff --git a/tests/TcpServerTest.php b/tests/TcpServerTest.php index 631de78..acba5b3 100644 --- a/tests/TcpServerTest.php +++ b/tests/TcpServerTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\JsonRpc; use Hyperf\Codec\Json; @@ -135,7 +136,7 @@ protected function getContainer() 'port' => 9504, 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ - Event::ON_RECEIVE => [\Hyperf\JsonRpc\TcpServer::class, 'onReceive'], + Event::ON_RECEIVE => [TcpServer::class, 'onReceive'], ], 'settings' => [ 'open_eof_split' => true,