Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
doubaokun committed Sep 8, 2024
1 parent d8d6303 commit e94e302
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/BaseStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -57,7 +57,7 @@ protected function _serverStreamRequest(
$method,
$request,
$deserialize,
array $metadata = []
array $metadata = [],
) {
$this->deserialize = $deserialize;
$streamId = $this->client->send($method, $request);
Expand Down
4 changes: 3 additions & 1 deletion src/Exception/ClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

namespace OpenSwoole\GRPC\Exception;

class ClientException extends GRPCException {}
class ClientException extends GRPCException
{
}
8 changes: 4 additions & 4 deletions src/Exception/GRPCException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

namespace OpenSwoole\GRPC;

interface MessageInterface {}
interface MessageInterface
{
}
4 changes: 3 additions & 1 deletion src/Middleware/MiddlewareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

namespace OpenSwoole\GRPC\Middleware;

interface MiddlewareInterface {}
interface MiddlewareInterface
{
}
4 changes: 3 additions & 1 deletion src/RequestHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

namespace OpenSwoole\GRPC;

interface RequestHandlerInterface {}
interface RequestHandlerInterface
{
}
4 changes: 2 additions & 2 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion src/ServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

namespace OpenSwoole\GRPC;

interface ServiceInterface {}
interface ServiceInterface
{
}

0 comments on commit e94e302

Please sign in to comment.