Skip to content

Commit

Permalink
use static instead of self for late static bindings in Server
Browse files Browse the repository at this point in the history
  • Loading branch information
astronom authored and 1ma committed Aug 24, 2020
1 parent 886da7b commit 727be66
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public function run(string $raw): ?string
$input = Input::fromString($raw, $this->simdJson);

if (!$input->parsable()) {
return self::end(Error::parsing());
return static::end(Error::parsing());
}

if ($input->isArray()) {
if ($this->tooManyBatchRequests($input)) {
return self::end(Error::tooManyBatchRequests($this->batchLimit));
return static::end(Error::tooManyBatchRequests($this->batchLimit));
}

return $this->batch($input);
Expand Down Expand Up @@ -118,25 +118,25 @@ protected function batch(Input $input): ?string
protected function single(Input $input): ?string
{
if (!$input->isRpcRequest()) {
return self::end(Error::invalidRequest());
return static::end(Error::invalidRequest());
}

$request = new Request($input);

if (!\array_key_exists($request->method(), $this->methods)) {
return self::end(Error::unknownMethod($request->id()), $request);
return static::end(Error::unknownMethod($request->id()), $request);
}

try {
$procedure = Assert::isProcedure(
$this->container->get($this->methods[$request->method()])
);
} catch (ContainerExceptionInterface | NotFoundExceptionInterface $e) {
return self::end(Error::internal($request->id()), $request);
return static::end(Error::internal($request->id()), $request);
}

if ($procedure->getSpec() instanceof stdClass && !Validator::validate($procedure->getSpec(), $request->params())) {
return self::end(Error::invalidParams($request->id()), $request);
return static::end(Error::invalidParams($request->id()), $request);
}

$stack = MiddlewareStack::compose(
Expand All @@ -146,7 +146,7 @@ protected function single(Input $input): ?string
}, \array_keys($this->middlewares))
);

return self::end($stack($request), $request);
return static::end($stack($request), $request);
}

protected function tooManyBatchRequests(Input $input): bool
Expand Down

0 comments on commit 727be66

Please sign in to comment.