Skip to content

Commit 60a4c53

Browse files
Merge pull request #233 from SpencerMalone/throw-on-json-encoding
Throw exception if we fail to json encode predefined error responses to appease phpstan
2 parents a47b602 + 2c8b0de commit 60a4c53

3 files changed

Lines changed: 2 additions & 14 deletions

File tree

lib/src/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private function writeNoRouteError(ServerRequestInterface $request): ResponseInt
8181
'meta' => [
8282
'twirp_invalid_route' => $request->getMethod().' '.$request->getUri()->getPath(),
8383
],
84-
]));
84+
], \JSON_THROW_ON_ERROR));
8585

8686
return $this->responseFactory
8787
->createResponse($statusCode)

lib/src/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private function writeNoRouteError(ServerRequestInterface $request): ResponseInt
7878
'meta' => [
7979
'twirp_invalid_route' => $request->getMethod().' '.$request->getUri()->getPath(),
8080
],
81-
]));
81+
], \JSON_THROW_ON_ERROR));
8282

8383
return $this->responseFactory
8484
->createResponse($statusCode)

phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,6 @@ parameters:
258258
count: 1
259259
path: lib/src/Context.php
260260

261-
-
262-
message: '#^Parameter \#1 \$content of method Psr\\Http\\Message\\StreamFactoryInterface\:\:createStream\(\) expects string, string\|false given\.$#'
263-
identifier: argument.type
264-
count: 1
265-
path: lib/src/Router.php
266-
267-
-
268-
message: '#^Parameter \#1 \$content of method Psr\\Http\\Message\\StreamFactoryInterface\:\:createStream\(\) expects string, string\|false given\.$#'
269-
identifier: argument.type
270-
count: 1
271-
path: lib/src/Server.php
272-
273261
-
274262
message: '#^Method Twirp\\ServerHooks\:\:error\(\) has parameter \$ctx with no value type specified in iterable type array\.$#'
275263
identifier: missingType.iterableValue

0 commit comments

Comments
 (0)