Fix static analysis error in testing traits (#2180) · devhammed/lighthouse@880f543 · GitHub
Skip to content

Commit 880f543

Browse files
authored
Fix static analysis error in testing traits (nuwave#2180)
1 parent 06acf09 commit 880f543

32 files changed

Lines changed: 257 additions & 158 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function bar(){
273273

274274
## Code style
275275

276-
We format the code automatically with [php-cs-fixer](https://github.com/friendsofphp/php-cs-fixer)
276+
We format the code automatically with [php-cs-fixer](https://github.com/friendsofphp/php-cs-fixer).
277277

278278
make fix
279279

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"config": {
8888
"allow-plugins": {
8989
"composer/package-versions-deprecated": true,
90-
"ergebnis/composer-normalize": true
90+
"ergebnis/composer-normalize": true,
91+
"kylekatarnls/update-helper": true
9192
},
9293
"sort-packages": true
9394
},

docs/5/digging-deeper/error-handling.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Head over their [Error Handling docs](https://webonyx.github.io/graphql-php/erro
1919
The interface [`\Nuwave\Lighthouse\Exceptions\RendersErrorsExtensions`](https://github.com/nuwave/lighthouse/blob/master/src/Exceptions/RendersErrorsExtensions.php)
2020
may be extended to add more information than just an error message to the rendered error output.
2121

22-
Let's say you want to have a custom exception type that contains information about
23-
the reason the exception was thrown.
22+
This custom exception contains information about the reason the exception was thrown:
2423

2524
```php
2625
<?php
@@ -46,9 +45,6 @@ class CustomException extends Exception implements RendersErrorsExtensions
4645

4746
/**
4847
* Returns true when exception message is safe to be displayed to a client.
49-
*
50-
* @api
51-
* @return bool
5248
*/
5349
public function isClientSafe(): bool
5450
{

docs/master/digging-deeper/error-handling.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Head over their [Error Handling docs](https://webonyx.github.io/graphql-php/erro
1919
The interface [`\Nuwave\Lighthouse\Exceptions\RendersErrorsExtensions`](https://github.com/nuwave/lighthouse/blob/master/src/Exceptions/RendersErrorsExtensions.php)
2020
may be extended to add more information than just an error message to the rendered error output.
2121

22-
Let's say you want to have a custom exception type that contains information about
23-
the reason the exception was thrown.
22+
This custom exception contains information about the reason the exception was thrown:
2423

2524
```php
2625
<?php
@@ -46,9 +45,6 @@ class CustomException extends Exception implements RendersErrorsExtensions
4645

4746
/**
4847
* Returns true when exception message is safe to be displayed to a client.
49-
*
50-
* @api
51-
* @return bool
5248
*/
5349
public function isClientSafe(): bool
5450
{

src/CacheControl/CacheControlServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function (StartExecution $startExecution) {
4343
$typeInfo = new TypeInfo($startExecution->schema);
4444

4545
Visitor::visit($startExecution->query, Visitor::visitWithTypeInfo($typeInfo, [
46-
NodeKind::FIELD => function (FieldNode $node) use ($typeInfo, $cacheControl): void {
46+
NodeKind::FIELD => function (FieldNode $_) use ($typeInfo, $cacheControl): void {
4747
$field = $typeInfo->getFieldDef();
4848
// @phpstan-ignore-next-line can be null, remove ignore with graphql-php 15
4949
if (null === $field) {

src/Console/PrintSchemaCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function handle(ASTCache $cache, Filesystem $storage, SchemaBuilder $sche
5252

5353
if ($this->option('write')) {
5454
$storage->put($filename, $schemaString);
55-
$this->info('Wrote schema to the default file storage (usually storage/app) as "' . $filename . '".');
55+
$this->info("Wrote schema to the default file storage (usually storage/app) as {$filename}.");
5656
} else {
5757
$this->info($schemaString);
5858
}

src/Federation/Directives/ExternalDirective.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ public static function definition(): string
2929

3030
public function resolveField(FieldValue $fieldValue): FieldValue
3131
{
32-
$fieldValue->setResolver(function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) {
32+
$defaultFieldResolver = Executor::getDefaultFieldResolver();
33+
34+
$fieldValue->setResolver(function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($defaultFieldResolver) {
3335
// The parent might just hold a foreign key to the external object, in which case we just return that.
3436
return is_scalar($root)
3537
? $root
36-
: (Executor::getDefaultFieldResolver())($root, $args, $context, $resolveInfo);
38+
: $defaultFieldResolver($root, $args, $context, $resolveInfo);
3739
});
3840

3941
return $fieldValue;

src/Federation/SchemaPrinter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use GraphQL\Type\Definition\ObjectType;
1010
use GraphQL\Type\Definition\Type;
1111
use GraphQL\Utils\SchemaPrinter as GraphQLSchemaPrinter;
12-
use GraphQL\Utils\Utils;
1312

1413
class SchemaPrinter extends GraphQLSchemaPrinter
1514
{
@@ -105,9 +104,12 @@ public static function printDirectives(array $directives): string
105104
return ' '
106105
. implode(
107106
' ',
108-
Utils::map($directives, static function (DirectiveNode $directive): string {
109-
return Printer::doPrint($directive);
110-
})
107+
array_map(
108+
static function (DirectiveNode $directive): string {
109+
return Printer::doPrint($directive);
110+
},
111+
$directives
112+
)
111113
);
112114
}
113115
}

src/GraphQL.php

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)