diff --git a/src/BaseStub.php b/src/BaseStub.php index d0a7eec..f83e0e5 100644 --- a/src/BaseStub.php +++ b/src/BaseStub.php @@ -30,7 +30,7 @@ protected function _simpleRequest( $method, $request, $deserialize, - array $metadata = [] + array $metadata = [], ) { $streamId = $this->client->send($method, $request); [$data, $trailers] = $this->client->recv($streamId); @@ -57,7 +57,7 @@ protected function _serverStreamRequest( $method, $request, $deserialize, - array $metadata = [] + array $metadata = [], ) { $this->deserialize = $deserialize; $streamId = $this->client->send($method, $request); diff --git a/src/Exception/ClientException.php b/src/Exception/ClientException.php index 7378098..c50e631 100644 --- a/src/Exception/ClientException.php +++ b/src/Exception/ClientException.php @@ -9,4 +9,6 @@ namespace OpenSwoole\GRPC\Exception; -class ClientException extends GRPCException {} +class ClientException extends GRPCException +{ +} diff --git a/src/Exception/GRPCException.php b/src/Exception/GRPCException.php index 746e764..e4b9f68 100644 --- a/src/Exception/GRPCException.php +++ b/src/Exception/GRPCException.php @@ -19,16 +19,16 @@ class GRPCException extends RuntimeException final public function __construct( string $message = '', - int $code = null, - Throwable $previous = null + ?int $code = null, + ?Throwable $previous = null, ) { parent::__construct($message, (int) ($code ?? static::CODE), $previous); } public static function create( string $message, - int $code = null, - Throwable $previous = null + ?int $code = null, + ?Throwable $previous = null, ): self { return new static($message, $code, $previous); } diff --git a/src/MessageInterface.php b/src/MessageInterface.php index d7cde01..652ffd2 100644 --- a/src/MessageInterface.php +++ b/src/MessageInterface.php @@ -9,4 +9,6 @@ namespace OpenSwoole\GRPC; -interface MessageInterface {} +interface MessageInterface +{ +} diff --git a/src/Middleware/MiddlewareInterface.php b/src/Middleware/MiddlewareInterface.php index ad44536..464a667 100644 --- a/src/Middleware/MiddlewareInterface.php +++ b/src/Middleware/MiddlewareInterface.php @@ -9,4 +9,6 @@ namespace OpenSwoole\GRPC\Middleware; -interface MiddlewareInterface {} +interface MiddlewareInterface +{ +} diff --git a/src/RequestHandlerInterface.php b/src/RequestHandlerInterface.php index 9277370..e375ddd 100644 --- a/src/RequestHandlerInterface.php +++ b/src/RequestHandlerInterface.php @@ -9,4 +9,6 @@ namespace OpenSwoole\GRPC; -interface RequestHandlerInterface {} +interface RequestHandlerInterface +{ +} diff --git a/src/Server.php b/src/Server.php index 5e8aadf..cb2bcc0 100644 --- a/src/Server.php +++ b/src/Server.php @@ -88,7 +88,7 @@ public function start() $this->server->set($this->settings); $this->server->on('workerStart', function (\OpenSwoole\Server $server, int $workerId) { $this->workerContext = new Context([ - \OpenSwoole\GRPC\Server::class => $this, + Server::class => $this, \OpenSwoole\HTTP\Server::class => $this->server, ]); foreach ($this->workerContexts as $context => $callback) { @@ -107,7 +107,7 @@ public function on(string $event, Closure $callback) return $this; } - public function register(string $class, ServiceInterface $instance = null): self + public function register(string $class, ?ServiceInterface $instance = null): self { if (!class_exists($class)) { throw new TypeError("{$class} not found"); diff --git a/src/ServiceContainer.php b/src/ServiceContainer.php index 122b239..1101693 100644 --- a/src/ServiceContainer.php +++ b/src/ServiceContainer.php @@ -120,7 +120,7 @@ private function discoverMethods(ServiceInterface $service): array $methods = []; foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { // Check if its a gRPC method before doing this check - if (count($method->getParameters()) > 0 && $method->getParameteres()[0]->getName() == 'ctx') { + if (count($method->getParameters()) > 0 && $method->getParameters()[0]->getName() == 'ctx') { // This is a gRPC method if ($method->getNumberOfParameters() !== 2) { throw new Exception('error method'); diff --git a/src/ServiceInterface.php b/src/ServiceInterface.php index 9c16421..805a15c 100644 --- a/src/ServiceInterface.php +++ b/src/ServiceInterface.php @@ -9,4 +9,6 @@ namespace OpenSwoole\GRPC; -interface ServiceInterface {} +interface ServiceInterface +{ +}