Skip to content

Commit e41a91b

Browse files
committed
Clean up and format
1 parent 5256b0f commit e41a91b

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

UPGRADE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ Before:
584584
```php
585585
use GraphQL\Validator\DocumentValidator;
586586

587-
$myRule = function(ValidationContext $context) {};
587+
$myRule = function (ValidationContext $context) {};
588588
DocumentValidator::validate($schema, $ast, [$myRule]);
589589
```
590590

@@ -594,7 +594,7 @@ After:
594594
use GraphQL\Validator\Rules\CustomValidationRule;
595595
use GraphQL\Validator\DocumentValidator;
596596

597-
$myRule = new CustomValidationRule('MyRule', function(ValidationContext $context) {});
597+
$myRule = new CustomValidationRule('MyRule', function (ValidationContext $context) {});
598598
DocumentValidator::validate($schema, $ast, [$myRule]);
599599
```
600600

@@ -605,7 +605,7 @@ Before the change:
605605
```php
606606
use GraphQL\Validator\DocumentValidator;
607607

608-
$myRule = function(ValidationContext $context) {};
608+
$myRule = function (ValidationContext $context) {};
609609
DocumentValidator::addRule('MyRuleName', $myRule);
610610
```
611611

@@ -614,7 +614,7 @@ After the change:
614614
```php
615615
use GraphQL\Validator\DocumentValidator;
616616

617-
$myRule = new CustomValidationRulefunction('MyRule', ValidationContext $context) {});
617+
$myRule = new CustomValidationRule('MyRule', function (ValidationContext $context) {});
618618
DocumentValidator::addRule($myRule);
619619
```
620620

src/Type/Definition/ObjectType.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919
* Example:
2020
*
2121
* $AddressType = new ObjectType([
22-
* 'name' => 'Address',
23-
* 'fields' => [
24-
* 'street' => [ 'type' => GraphQL\Type\Definition\Type::string() ],
25-
* 'number' => [ 'type' => GraphQL\Type\Definition\Type::int() ],
26-
* 'formatted' => [
27-
* 'type' => GraphQL\Type\Definition\Type::string(),
28-
* 'resolve' => function($obj) {
29-
* return $obj->number . ' ' . $obj->street;
30-
* }
31-
* ]
32-
* ]
22+
* 'name' => 'Address',
23+
* 'fields' => [
24+
* 'street' => GraphQL\Type\Definition\Type::string(),
25+
* 'number' => GraphQL\Type\Definition\Type::int(),
26+
* 'formatted' => [
27+
* 'type' => GraphQL\Type\Definition\Type::string(),
28+
* 'resolve' => fn (AddressModel $address): string => "{$address->number} {$address->street}",
29+
* ],
30+
* ],
3331
* ]);
3432
*
3533
* When two types need to refer to each other, or a type needs to refer to
@@ -40,13 +38,11 @@
4038
*
4139
* $PersonType = null;
4240
* $PersonType = new ObjectType([
43-
* 'name' => 'Person',
44-
* 'fields' => function() use (&$PersonType) {
45-
* return [
46-
* 'name' => ['type' => GraphQL\Type\Definition\Type::string() ],
47-
* 'bestFriend' => [ 'type' => $PersonType ],
48-
* ];
49-
* }
41+
* 'name' => 'Person',
42+
* 'fields' => fn (): array => [
43+
* 'name' => GraphQL\Type\Definition\Type::string(),
44+
* 'bestFriend' => $PersonType,
45+
* ],
5046
* ]);
5147
*
5248
* @phpstan-import-type FieldResolver from Executor

tests/Server/QueryExecutionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ public function testDebugExceptions(): void
113113
'path' => ['fieldWithSafeException'],
114114
'extensions' => [
115115
'trace' => [],
116+
'line' => 40,
117+
'file' => __DIR__ . '/ServerTestCase.php',
116118
],
117119
],
118120
],
119121
];
120122

121123
$result = $this->executeQuery($query)->toArray();
122124
self::assertArraySubset($expected, $result);
123-
self::assertSame(40, $result['errors'][0]['extensions']['line'] ?? null);
124-
self::assertStringContainsString('tests/Server/ServerTestCase.php', $result['errors'][0]['extensions']['file'] ?? '');
125125
}
126126

127127
public function testRethrowUnsafeExceptions(): void

0 commit comments

Comments
 (0)