diff --git a/composer.json b/composer.json
index b549958..8084e4a 100644
--- a/composer.json
+++ b/composer.json
@@ -24,7 +24,7 @@
"require-dev": {
"ergebnis/composer-normalize": "^2.11",
"jangregor/phpstan-prophecy": "^1",
- "mll-lab/php-cs-fixer-config": "^4.4",
+ "mll-lab/php-cs-fixer-config": "^5",
"orchestra/testbench": "~3.6.0 || ~3.7.0 || ~3.8.0 || ~3.9.0 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9 || ^9.x-dev",
"phpstan/extension-installer": "^1",
"phpstan/phpstan": "^1",
diff --git a/phpunit.xml b/phpunit.xml
index a7f5136..da05c57 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,8 +1,7 @@
@@ -11,7 +10,7 @@
diff --git a/src/BadMultipartRequestGraphQLException.php b/src/BadMultipartRequestGraphQLException.php
index 7dec415..e6ac363 100644
--- a/src/BadMultipartRequestGraphQLException.php
+++ b/src/BadMultipartRequestGraphQLException.php
@@ -6,10 +6,8 @@
class BadMultipartRequestGraphQLException extends BadRequestHttpException
{
- /**
- * @param array $headers
- */
- public function __construct(string $message, \Throwable $previous = null, int $code = 0, array $headers = [])
+ /** @param array $headers */
+ public function __construct(string $message, ?\Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(
"{$message} Be sure to conform to the GraphQL multipart request specification (https://github.com/jaydenseric/graphql-multipart-request-spec).",
diff --git a/src/BadRequestGraphQLException.php b/src/BadRequestGraphQLException.php
index d94b8e1..5c77ba4 100644
--- a/src/BadRequestGraphQLException.php
+++ b/src/BadRequestGraphQLException.php
@@ -4,6 +4,4 @@
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
-class BadRequestGraphQLException extends BadRequestHttpException
-{
-}
+class BadRequestGraphQLException extends BadRequestHttpException {}
diff --git a/src/RequestParser.php b/src/RequestParser.php
index 5bca090..1844278 100644
--- a/src/RequestParser.php
+++ b/src/RequestParser.php
@@ -7,16 +7,13 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Safe\Exceptions\JsonException;
+
use function Safe\json_decode;
-/**
- * Follows https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md.
- */
+/** Follows https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md. */
class RequestParser
{
- /**
- * @var \GraphQL\Server\Helper
- */
+ /** @var Helper */
protected $helper;
public function __construct()
@@ -28,15 +25,15 @@ public function __construct()
* Converts an incoming HTTP request to one or more OperationParams.
*
* @throws \GraphQL\Server\RequestError
- * @throws \Laragraph\Utils\BadRequestGraphQLException
- * @throws \Laragraph\Utils\BadMultipartRequestGraphQLException
+ * @throws BadRequestGraphQLException
+ * @throws BadMultipartRequestGraphQLException
*
* @return \GraphQL\Server\OperationParams|array
*/
public function parseRequest(Request $request)
{
$method = $request->getMethod();
- $bodyParams = 'POST' === $method
+ $bodyParams = $method === 'POST'
? $this->bodyParams($request)
: [];
/** @var array $queryParams Laravel type is not precise enough */
@@ -48,8 +45,8 @@ public function parseRequest(Request $request)
/**
* Extracts the body parameters from the request.
*
- * @throws \Laragraph\Utils\BadMultipartRequestGraphQLException
- * @throws \Laragraph\Utils\BadRequestGraphQLException
+ * @throws BadMultipartRequestGraphQLException
+ * @throws BadRequestGraphQLException
*
* @return array
*/
@@ -96,14 +93,14 @@ protected function bodyParams(Request $request): array
*
* Follows https://github.com/jaydenseric/graphql-multipart-request-spec.
*
- * @throws \Laragraph\Utils\BadMultipartRequestGraphQLException
+ * @throws BadMultipartRequestGraphQLException
*
* @return array
*/
protected function inlineFiles(Request $request): array
{
$mapParam = $request->post('map');
- if (null === $mapParam) {
+ if ($mapParam === null) {
throw new BadMultipartRequestGraphQLException('Missing parameter map.');
}
if (! is_string($mapParam)) {
@@ -112,7 +109,7 @@ protected function inlineFiles(Request $request): array
}
$operationsParam = $request->post('operations');
- if (null === $operationsParam) {
+ if ($operationsParam === null) {
throw new BadMultipartRequestGraphQLException('Missing parameter operations.');
}
if (! is_string($operationsParam)) {
diff --git a/tests/Unit/RequestParserTest.php b/tests/Unit/RequestParserTest.php
index a4834ca..e8460fb 100644
--- a/tests/Unit/RequestParserTest.php
+++ b/tests/Unit/RequestParserTest.php
@@ -24,9 +24,7 @@ public function testGetWithQuery(): void
self::assertSame($query, $params->query);
}
- /**
- * @dataProvider jsonLikeContentTypes
- */
+ /** @dataProvider jsonLikeContentTypes */
public function testPostWithJsonLike(string $contentType): void
{
$query = /** @lang GraphQL */ '{ foo }';
@@ -43,9 +41,7 @@ public function testPostWithJsonLike(string $contentType): void
self::assertSame($query, $params->query);
}
- /**
- * @return iterable
- */
+ /** @return iterable */
public static function jsonLikeContentTypes(): iterable
{
yield ['application/json'];
@@ -53,9 +49,7 @@ public static function jsonLikeContentTypes(): iterable
yield ['application/json;charset=UTF-8'];
}
- /**
- * @dataProvider graphQLContentTypes
- */
+ /** @dataProvider graphQLContentTypes */
public function testPostWithQueryApplicationGraphQL(string $contentType): void
{
$query = /** @lang GraphQL */ '{ foo }';
@@ -72,18 +66,14 @@ public function testPostWithQueryApplicationGraphQL(string $contentType): void
self::assertSame($query, $params->query);
}
- /**
- * @return iterable
- */
+ /** @return iterable */
public static function graphQLContentTypes(): iterable
{
yield ['application/graphql'];
yield ['application/graphql;charset=UTF-8'];
}
- /**
- * @dataProvider formContentTypes
- */
+ /** @dataProvider formContentTypes */
public function testPostWithRegularForm(string $contentType): void
{
$query = /** @lang GraphQL */ '{ foo }';
@@ -100,9 +90,7 @@ public function testPostWithRegularForm(string $contentType): void
self::assertSame($query, $params->query);
}
- /**
- * @return iterable
- */
+ /** @return iterable */
public static function formContentTypes(): iterable
{
yield ['application/x-www-form-urlencoded'];
@@ -145,9 +133,7 @@ public function testPostDefaultsToRegularForm(): void
self::assertSame($query, $params->query);
}
- /**
- * @dataProvider nonsensicalContentTypes
- */
+ /** @dataProvider nonsensicalContentTypes */
public function testNonsensicalContentTypes(string $contentType): void
{
$request = $this->makeRequest(
@@ -163,9 +149,7 @@ public function testNonsensicalContentTypes(string $contentType): void
$parser->parseRequest($request);
}
- /**
- * @return iterable
- */
+ /** @return iterable */
public static function nonsensicalContentTypes(): iterable
{
yield ['foobar'];
@@ -217,9 +201,7 @@ public function testNonArrayJson(): void
$parser->parseRequest($request);
}
- /**
- * @dataProvider multipartFormContentTypes
- */
+ /** @dataProvider multipartFormContentTypes */
public function testMultipartFormRequest(string $contentType): void
{
$file = UploadedFile::fake()->create('image.jpg', 500);
@@ -260,9 +242,7 @@ public function testMultipartFormRequest(string $contentType): void
self::assertSame($file, $variables['file']);
}
- /**
- * @return iterable
- */
+ /** @return iterable */
public static function multipartFormContentTypes(): iterable
{
yield ['multipart/form-data'];