Skip to content

Commit 0d8ea16

Browse files
k0kagithub-actions[bot]
authored andcommitted
Apply php-cs-fixer changes
1 parent ec9f70f commit 0d8ea16

File tree

8 files changed

+39
-31
lines changed

8 files changed

+39
-31
lines changed

benchmarks/HugeRequestBench.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,20 @@ final class HugeRequestBench extends QueryBench
1010
@field(resolver: "Benchmarks\\HugeRequestBench@resolve")
1111
}
1212
GRAPHQL;
13+
1314
protected ?string $query = null;
1415

1516
/**
1617
* Resolves foo.
1718
*
1819
* @skip
19-
*
20-
* @return string
2120
*/
2221
public function resolve(): string
2322
{
24-
return "foo";
23+
return 'foo';
2524
}
2625

27-
/**
28-
* Generates query with $count fragments.
29-
*/
26+
/** Generates query with $count fragments. */
3027
private function generateQuery(int $count): string
3128
{
3229
$query = '{';
@@ -45,10 +42,13 @@ private function generateQuery(int $count): string
4542

4643
/**
4744
* @Warmup(1)
45+
*
4846
* @Revs(10)
47+
*
4948
* @Iterations(10)
5049
*
5150
* @ParamProviders({"providePerformanceTuning"})
51+
*
5252
* @BeforeMethods("setPerformanceTuning")
5353
*/
5454
public function benchmark1(): void
@@ -59,10 +59,13 @@ public function benchmark1(): void
5959

6060
/**
6161
* @Warmup(1)
62+
*
6263
* @Revs(10)
64+
*
6365
* @Iterations(10)
6466
*
6567
* @ParamProviders({"providePerformanceTuning"})
68+
*
6669
* @BeforeMethods("setPerformanceTuning")
6770
*/
6871
public function benchmark10(): void
@@ -75,10 +78,13 @@ public function benchmark10(): void
7578

7679
/**
7780
* @Warmup(1)
81+
*
7882
* @Revs(10)
83+
*
7984
* @Iterations(10)
8085
*
8186
* @ParamProviders({"providePerformanceTuning"})
87+
*
8288
* @BeforeMethods("setPerformanceTuning")
8389
*/
8490
public function benchmark100(): void

benchmarks/HugeResponseBench.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ public function resolve(): array
5151

5252
/**
5353
* @Warmup(1)
54+
*
5455
* @Revs(10)
56+
*
5557
* @Iterations(10)
5658
*
5759
* @ParamProviders({"providePerformanceTuning"})
60+
*
5861
* @BeforeMethods("setPerformanceTuning")
5962
*/
6063
public function benchmark1(): void
@@ -70,10 +73,13 @@ public function benchmark1(): void
7073

7174
/**
7275
* @Warmup(1)
76+
*
7377
* @Revs(10)
78+
*
7479
* @Iterations(1)
7580
*
7681
* @ParamProviders({"providePerformanceTuning"})
82+
*
7783
* @BeforeMethods("setPerformanceTuning")
7884
*/
7985
public function benchmark100(): void
@@ -91,10 +97,13 @@ public function benchmark100(): void
9197

9298
/**
9399
* @Warmup(1)
100+
*
94101
* @Revs(10)
102+
*
95103
* @Iterations(10)
96104
*
97105
* @ParamProviders({"providePerformanceTuning"})
106+
*
98107
* @BeforeMethods("setPerformanceTuning")
99108
*/
100109
public function benchmark10k(): void

benchmarks/QueryBench.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ protected function graphQLEndpointUrl(array $routeParams = []): string
3434
return $this->graphQLEndpoint;
3535
}
3636

37-
/**
38-
* Set up function with the performance tuning.
39-
*/
37+
/** Set up function with the performance tuning. */
4038
public function setPerformanceTuning(array $params): void
4139
{
4240
$this->setUp();
43-
if ($params[0]){
41+
if ($params[0]) {
4442
$this->app->make(ConfigRepository::class)->set('lighthouse.field_middleware', []);
4543
}
4644
$this->app->make(ConfigRepository::class)->set('lighthouse.query_cache.enable', $params[1]);

src/Execution/CacheableValidationRulesProvider.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,23 @@ public function __construct(
1818
public function cacheableValidationRules(): array
1919
{
2020
$result = [
21-
QueryDepth::class => new QueryDepth($this->configRepository->get('lighthouse.security.max_query_depth', 0)),
22-
DisableIntrospection::class => new DisableIntrospection($this->configRepository->get('lighthouse.security.disable_introspection', 0)),
23-
] + DocumentValidator::allRules();
21+
QueryDepth::class => new QueryDepth($this->configRepository->get('lighthouse.security.max_query_depth', 0)),
22+
DisableIntrospection::class => new DisableIntrospection($this->configRepository->get('lighthouse.security.disable_introspection', 0)),
23+
] + DocumentValidator::allRules();
2424

2525
unset($result[QueryComplexity::class]);
26+
2627
return $result;
2728
}
2829

2930
public function validationRules(): ?array
3031
{
3132
$maxQueryComplexity = $this->configRepository->get('lighthouse.security.max_query_complexity', 0);
33+
3234
return $maxQueryComplexity === 0
3335
? []
3436
: [
3537
QueryComplexity::class => new QueryComplexity($maxQueryComplexity),
3638
];
37-
3839
}
3940
}

src/GraphQL.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function executeOperation(OperationParams $params, GraphQLContext $contex
248248
$params->variables,
249249
null,
250250
$params->operation,
251-
$params->queryId
251+
$params->queryId,
252252
);
253253
} catch (\Throwable $throwable) {
254254
return $this->toSerializableArray(
@@ -264,7 +264,7 @@ public function executeOperation(OperationParams $params, GraphQLContext $contex
264264
*
265265
* @api
266266
*/
267-
public function parse(string $query, string &$hash = null): DocumentNode
267+
public function parse(string $query, ?string &$hash = null): DocumentNode
268268
{
269269
$cacheConfig = $this->configRepository->get('lighthouse.query_cache');
270270
$hash = hash('sha256', $query);
@@ -385,29 +385,25 @@ protected function parseQuery(string $query): DocumentNode
385385
]);
386386
}
387387

388-
389388
/**
390389
* Execute the validation rules that are cacheable.
391390
*
392391
* @return array<Error>
393-
*
394-
* @throws \Exception
395392
*/
396393
protected function executeAndCacheValidationRules(
397394
SchemaType $schema,
398395
?string $schemaHash,
399396
DocumentNode $query,
400-
?string $queryHash
401-
): array
402-
{
403-
if (!$this->providesValidationRules instanceof ProvidesCacheableValidationRules) {
397+
?string $queryHash,
398+
): array {
399+
if (! $this->providesValidationRules instanceof ProvidesCacheableValidationRules) {
404400
return [];
405401
}
406402

407403
$validationRules = $this->providesValidationRules->cacheableValidationRules();
408404
foreach ($validationRules as $rule) {
409405
if ($rule instanceof QueryComplexity) {
410-
throw new \InvalidArgumentException("QueryComplexity rule should not be registered in cacheableValidationRules");
406+
throw new \InvalidArgumentException('QueryComplexity rule should not be registered in cacheableValidationRules');
411407
}
412408
}
413409

@@ -422,7 +418,7 @@ protected function executeAndCacheValidationRules(
422418
/** @var CacheFactory $cacheFactory */
423419
$cacheFactory = Container::getInstance()->make(CacheFactory::class);
424420
$store = $cacheFactory->store($cacheConfig['store']);
425-
if ($store->get($cacheKey) === true){
421+
if ($store->get($cacheKey) === true) {
426422
return [];
427423
}
428424

@@ -432,6 +428,7 @@ protected function executeAndCacheValidationRules(
432428
}
433429

434430
$store->put($cacheKey, true, $cacheConfig['ttl']);
431+
435432
return [];
436433
}
437434
}

src/LighthouseServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function provideSubscriptionResolver(FieldValue $fieldValue): \Closure
101101
}
102102
});
103103

104-
//$this->app->bind(ProvidesValidationRules::class, ValidationRulesProvider::class);
104+
// $this->app->bind(ProvidesValidationRules::class, ValidationRulesProvider::class);
105105
$this->app->bind(ProvidesValidationRules::class, CacheableValidationRulesProvider::class);
106106

107107
$this->commands(self::COMMANDS);

src/Schema/AST/DocumentAST.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ class DocumentAST implements Arrayable
9090
/** @var array<int,SchemaExtensionNode> */
9191
public array $schemaExtensions = [];
9292

93-
/**
94-
* A hash of the schema.
95-
*/
93+
/** A hash of the schema. */
9694
public ?string $hash = null;
9795

9896
/** Create a new DocumentAST instance from a schema. */

tests/Integration/ValidationCachingTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public function testConfigMissing(): void
9595
Event::assertDispatchedTimes(KeyWritten::class, 0);
9696
}
9797

98-
9998
public function testErrorsAreNotCached(): void
10099
{
101100
$config = $this->app->make(ConfigRepository::class);
@@ -242,7 +241,7 @@ public function testDifferentSchemasHasDifferentKeys(): void
242241
{
243242
foo
244243
}
245-
')->assertGraphQLErrorMessage('Cannot query field "foo" on type "Query".');;
244+
')->assertGraphQLErrorMessage('Cannot query field "foo" on type "Query".');
246245

247246
Event::assertDispatchedTimes(CacheMissed::class, 1);
248247
Event::assertDispatchedTimes(CacheHit::class, 0);

0 commit comments

Comments
 (0)