diff --git a/src/App.php b/src/App.php index 0caa08f..1994e19 100644 --- a/src/App.php +++ b/src/App.php @@ -77,7 +77,7 @@ public function handle(string $content = '') $parser = new Parser($content); if ($this->checkBatchSizeWithinLimit($parser->countBatchingRequests())) { - return $this->makeResponse(new MaxBatchSizeExceededException()); + return $this->makeResponse(new MaxBatchSizeExceededException); } $result = collect($parser->makeRequests()) @@ -110,7 +110,7 @@ public function handleProcedure(Request $request, bool $notification): Response $procedure = $this->findProcedure($request); if ($procedure === null) { - return $this->makeResponse(new MethodNotFound(), $request); + return $this->makeResponse(new MethodNotFound, $request); } $result = $notification diff --git a/src/Docs.php b/src/Docs.php index 7a3680d..8b891b2 100644 --- a/src/Docs.php +++ b/src/Docs.php @@ -90,7 +90,7 @@ public function getAnnotations(): Collection */ private function getMethodAnnotations(ReflectionMethod $method, string $class): array { - $repository = new Repository(); + $repository = new Repository; $values = $this ->getAnnotationsFrom($method, $class) @@ -117,7 +117,7 @@ private function getMethodAnnotations(ReflectionMethod $method, string $class): */ private function getAnnotationsFrom(ReflectionMethod $method, string $class): Collection { - $annotations = (new AnnotationReader())->getMethodAnnotations($method); + $annotations = (new AnnotationReader)->getMethodAnnotations($method); return collect($annotations)->filter(fn ($annotation) => is_a($annotation, $class)); } diff --git a/src/HandleProcedure.php b/src/HandleProcedure.php index 3d82f16..9169f4d 100644 --- a/src/HandleProcedure.php +++ b/src/HandleProcedure.php @@ -87,7 +87,7 @@ protected function handleException(Throwable $exception) : $exception->getCode(); if ($code === 500) { - return new InternalErrorException(); + return new InternalErrorException; } if (! is_int($code)) { diff --git a/src/Http/Parser.php b/src/Http/Parser.php index 81fe661..32fe76b 100644 --- a/src/Http/Parser.php +++ b/src/Http/Parser.php @@ -147,11 +147,11 @@ public function countBatchingRequests(): int public function checkValidation($options = []) { if ($this->isError()) { - return new ParseErrorException(); + return new ParseErrorException; } if (! is_array($options) || Arr::isList($options)) { - return new InvalidRequestException(); + return new InvalidRequestException; } $data = $options; @@ -179,7 +179,7 @@ public static function rules(): array 'jsonrpc' => 'required|in:"2.0"', 'method' => 'required|string', 'params' => 'array', - 'id' => new Identifier(), + 'id' => new Identifier, ]; } } diff --git a/src/Http/Request.php b/src/Http/Request.php index 092fb93..3404b9d 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -53,7 +53,7 @@ public function __construct() */ public static function loadArray(array $collection): Request { - $request = new static(); + $request = new static; $methods = get_class_methods($request); collect($collection) diff --git a/src/Http/Response.php b/src/Http/Response.php index 5aaef8f..b58e9f9 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -38,10 +38,10 @@ class Response implements JsonSerializable */ public static function makeFromResult($result, ?Request $request = null): self { - $request ??= new Request(); + $request ??= new Request; return tap( - new self(), + new self, fn (Response $response) => $response->setId($request->getId()) ->setVersion($request->getVersion()) ->setResult($result) diff --git a/tests/FixtureProcedure.php b/tests/FixtureProcedure.php index feb32a8..d2ef080 100644 --- a/tests/FixtureProcedure.php +++ b/tests/FixtureProcedure.php @@ -84,7 +84,7 @@ public function ok(): string public function runtimeError() { - throw new RuntimeRpcException(); + throw new RuntimeRpcException; } public function invalidRequestException() @@ -108,7 +108,7 @@ public function reportException(): mixed */ public function renderException(): mixed { - throw new RenderResponseException(); + throw new RenderResponseException; } /** diff --git a/tests/Unit/AppTest.php b/tests/Unit/AppTest.php index d489e7d..3c65295 100644 --- a/tests/Unit/AppTest.php +++ b/tests/Unit/AppTest.php @@ -52,7 +52,7 @@ public function testExtendsProcedure(): void public function testFindMethodProcedure(): void { - $request = tap(new Request(), static function (Request $request) { + $request = tap(new Request, static function (Request $request) { $request->setId(1); $request->setMethod('fixture@subtract'); $request->setParams([42, 23]); @@ -64,7 +64,7 @@ public function testFindMethodProcedure(): void public function testNotFoundMethodProcedure(): void { - $request = tap(new Request(), static function (Request $request) { + $request = tap(new Request, static function (Request $request) { $request->setId(1); $request->setMethod('notFoundMethod'); $request->setParams([42, 23]); diff --git a/tests/Unit/RequestTest.php b/tests/Unit/RequestTest.php index 11a9d50..7bc8a57 100644 --- a/tests/Unit/RequestTest.php +++ b/tests/Unit/RequestTest.php @@ -11,7 +11,7 @@ class RequestTest extends TestCase { public function testFillableRequest(): void { - $request = tap(new Request(), static function (Request $request) { + $request = tap(new Request, static function (Request $request) { $request->setId(1); $request->setMethod('subtract'); $request->setParams([42, 23]); @@ -26,7 +26,7 @@ public function testFillableRequest(): void public function testRevertRequest(): void { - $request = tap(new Request(), static function (Request $request) { + $request = tap(new Request, static function (Request $request) { $request->setId(1); $request->setMethod('subtract'); $request->setParams([42, 23]);