Skip to content

Commit 515e5a3

Browse files
authored
Format and simplify
1 parent f8743fa commit 515e5a3

File tree

6 files changed

+25
-52
lines changed

6 files changed

+25
-52
lines changed

.github/workflows/autoformat.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
extensions: mbstring
1919
php-version: 8.3
2020

21-
- run: composer install --no-interaction --no-progress --no-suggest
21+
- run: composer install --no-interaction --no-progress
2222

2323
- run: composer normalize
2424

@@ -54,7 +54,7 @@ jobs:
5454
extensions: mbstring
5555
php-version: 7.2
5656

57-
- run: composer install --no-interaction --no-progress --no-suggest
57+
- run: composer install --no-interaction --no-progress
5858

5959
- run: vendor/bin/php-cs-fixer fix
6060

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"require-dev": {
2525
"ergebnis/composer-normalize": "^2.11",
2626
"jangregor/phpstan-prophecy": "^1",
27-
"mll-lab/php-cs-fixer-config": "^4.4",
27+
"mll-lab/php-cs-fixer-config": "^4",
2828
"orchestra/testbench": "~3.6.0 || ~3.7.0 || ~3.8.0 || ~3.9.0 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9 || ^9.x-dev",
2929
"phpstan/extension-installer": "^1",
3030
"phpstan/phpstan": "^1",

phpunit.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0"?>
22
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
5-
cacheDirectory=".phpunit.result.cache"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
65
>
76
<testsuites>
87
<testsuite name="Unit">
@@ -11,7 +10,7 @@
1110
</testsuites>
1211
<source>
1312
<include>
14-
<directory suffix=".php">src</directory>
13+
<directory>src</directory>
1514
</include>
1615
</source>
1716
</phpunit>

src/BadMultipartRequestGraphQLException.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77
class BadMultipartRequestGraphQLException extends BadRequestHttpException
88
{
9-
/**
10-
* @param array<mixed> $headers
11-
*/
12-
public function __construct(string $message, \Throwable $previous = null, int $code = 0, array $headers = [])
9+
/** @param array<mixed> $headers */
10+
public function __construct(string $message, ?\Throwable $previous = null, int $code = 0, array $headers = [])
1311
{
1412
parent::__construct(
1513
"{$message} Be sure to conform to the GraphQL multipart request specification (https://github.com/jaydenseric/graphql-multipart-request-spec).",

src/RequestParser.php

+7-11
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99
use Safe\Exceptions\JsonException;
1010
use function Safe\json_decode;
1111

12-
/**
13-
* Follows https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md.
14-
*/
12+
/** Follows https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md. */
1513
class RequestParser
1614
{
17-
/**
18-
* @var \GraphQL\Server\Helper
19-
*/
15+
/** @var Helper */
2016
protected $helper;
2117

2218
public function __construct()
@@ -28,8 +24,8 @@ public function __construct()
2824
* Converts an incoming HTTP request to one or more OperationParams.
2925
*
3026
* @throws \GraphQL\Server\RequestError
31-
* @throws \Laragraph\Utils\BadRequestGraphQLException
32-
* @throws \Laragraph\Utils\BadMultipartRequestGraphQLException
27+
* @throws BadRequestGraphQLException
28+
* @throws BadMultipartRequestGraphQLException
3329
*
3430
* @return \GraphQL\Server\OperationParams|array<int, \GraphQL\Server\OperationParams>
3531
*/
@@ -48,8 +44,8 @@ public function parseRequest(Request $request)
4844
/**
4945
* Extracts the body parameters from the request.
5046
*
51-
* @throws \Laragraph\Utils\BadMultipartRequestGraphQLException
52-
* @throws \Laragraph\Utils\BadRequestGraphQLException
47+
* @throws BadMultipartRequestGraphQLException
48+
* @throws BadRequestGraphQLException
5349
*
5450
* @return array<mixed>
5551
*/
@@ -96,7 +92,7 @@ protected function bodyParams(Request $request): array
9692
*
9793
* Follows https://github.com/jaydenseric/graphql-multipart-request-spec.
9894
*
99-
* @throws \Laragraph\Utils\BadMultipartRequestGraphQLException
95+
* @throws BadMultipartRequestGraphQLException
10096
*
10197
* @return array<mixed>
10298
*/

tests/Unit/RequestParserTest.php

+10-30
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ public function testGetWithQuery(): void
2424
self::assertSame($query, $params->query);
2525
}
2626

27-
/**
28-
* @dataProvider jsonLikeContentTypes
29-
*/
27+
/** @dataProvider jsonLikeContentTypes */
3028
public function testPostWithJsonLike(string $contentType): void
3129
{
3230
$query = /** @lang GraphQL */ '{ foo }';
@@ -43,19 +41,15 @@ public function testPostWithJsonLike(string $contentType): void
4341
self::assertSame($query, $params->query);
4442
}
4543

46-
/**
47-
* @return iterable<array{string}>
48-
*/
44+
/** @return iterable<array{string}> */
4945
public static function jsonLikeContentTypes(): iterable
5046
{
5147
yield ['application/json'];
5248
yield ['application/graphql+json'];
5349
yield ['application/json;charset=UTF-8'];
5450
}
5551

56-
/**
57-
* @dataProvider graphQLContentTypes
58-
*/
52+
/** @dataProvider graphQLContentTypes */
5953
public function testPostWithQueryApplicationGraphQL(string $contentType): void
6054
{
6155
$query = /** @lang GraphQL */ '{ foo }';
@@ -72,18 +66,14 @@ public function testPostWithQueryApplicationGraphQL(string $contentType): void
7266
self::assertSame($query, $params->query);
7367
}
7468

75-
/**
76-
* @return iterable<array{string}>
77-
*/
69+
/** @return iterable<array{string}> */
7870
public static function graphQLContentTypes(): iterable
7971
{
8072
yield ['application/graphql'];
8173
yield ['application/graphql;charset=UTF-8'];
8274
}
8375

84-
/**
85-
* @dataProvider formContentTypes
86-
*/
76+
/** @dataProvider formContentTypes */
8777
public function testPostWithRegularForm(string $contentType): void
8878
{
8979
$query = /** @lang GraphQL */ '{ foo }';
@@ -100,9 +90,7 @@ public function testPostWithRegularForm(string $contentType): void
10090
self::assertSame($query, $params->query);
10191
}
10292

103-
/**
104-
* @return iterable<array{string}>
105-
*/
93+
/** @return iterable<array{string}> */
10694
public static function formContentTypes(): iterable
10795
{
10896
yield ['application/x-www-form-urlencoded'];
@@ -145,9 +133,7 @@ public function testPostDefaultsToRegularForm(): void
145133
self::assertSame($query, $params->query);
146134
}
147135

148-
/**
149-
* @dataProvider nonsensicalContentTypes
150-
*/
136+
/** @dataProvider nonsensicalContentTypes */
151137
public function testNonsensicalContentTypes(string $contentType): void
152138
{
153139
$request = $this->makeRequest(
@@ -163,9 +149,7 @@ public function testNonsensicalContentTypes(string $contentType): void
163149
$parser->parseRequest($request);
164150
}
165151

166-
/**
167-
* @return iterable<array{string}>
168-
*/
152+
/** @return iterable<array{string}> */
169153
public static function nonsensicalContentTypes(): iterable
170154
{
171155
yield ['foobar'];
@@ -217,9 +201,7 @@ public function testNonArrayJson(): void
217201
$parser->parseRequest($request);
218202
}
219203

220-
/**
221-
* @dataProvider multipartFormContentTypes
222-
*/
204+
/** @dataProvider multipartFormContentTypes */
223205
public function testMultipartFormRequest(string $contentType): void
224206
{
225207
$file = UploadedFile::fake()->create('image.jpg', 500);
@@ -260,9 +242,7 @@ public function testMultipartFormRequest(string $contentType): void
260242
self::assertSame($file, $variables['file']);
261243
}
262244

263-
/**
264-
* @return iterable<array{string}>
265-
*/
245+
/** @return iterable<array{string}> */
266246
public static function multipartFormContentTypes(): iterable
267247
{
268248
yield ['multipart/form-data'];

0 commit comments

Comments
 (0)