Skip to content

Commit 9e675b5

Browse files
authored
Narrow errors type to list
1 parent 87f9564 commit 9e675b5

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

docs/class-reference.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,14 +1424,14 @@ locations?: array<int, array{line: int, column: int}>,
14241424
path?: array<int, int|string>,
14251425
extensions?: array<string, mixed>
14261426
}
1427-
@phpstan-type SerializableErrors array<int, SerializableError>
1427+
@phpstan-type SerializableErrors list<SerializableError>
14281428
@phpstan-type SerializableResult array{
14291429
data?: array<string, mixed>,
14301430
errors?: SerializableErrors,
14311431
extensions?: array<string, mixed>
14321432
}
14331433
@phpstan-type ErrorFormatter callable(\Throwable): SerializableError
1434-
@phpstan-type ErrorsHandler callable(array<Error> $errors, ErrorFormatter $formatter): SerializableErrors
1434+
@phpstan-type ErrorsHandler callable(list<Error> $errors, ErrorFormatter $formatter): SerializableErrors
14351435

14361436
@see \GraphQL\Tests\Executor\ExecutionResultTest
14371437

@@ -1455,7 +1455,7 @@ public $data;
14551455
*
14561456
* @api
14571457
*
1458-
* @var array<Error>
1458+
* @var list<Error>
14591459
*/
14601460
public $errors;
14611461

@@ -1642,7 +1642,7 @@ will be created from the provided schema.
16421642
*
16431643
* @throws \Exception
16441644
*
1645-
* @return array<int, Error>
1645+
* @return list<Error>
16461646
*
16471647
* @api
16481648
*/

src/Executor/ExecutionResult.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
* path?: array<int, int|string>,
2121
* extensions?: array<string, mixed>
2222
* }
23-
* @phpstan-type SerializableErrors array<int, SerializableError>
23+
* @phpstan-type SerializableErrors list<SerializableError>
2424
* @phpstan-type SerializableResult array{
2525
* data?: array<string, mixed>,
2626
* errors?: SerializableErrors,
2727
* extensions?: array<string, mixed>
2828
* }
2929
* @phpstan-type ErrorFormatter callable(\Throwable): SerializableError
30-
* @phpstan-type ErrorsHandler callable(array<Error> $errors, ErrorFormatter $formatter): SerializableErrors
30+
* @phpstan-type ErrorsHandler callable(list<Error> $errors, ErrorFormatter $formatter): SerializableErrors
3131
*
3232
* @see \GraphQL\Tests\Executor\ExecutionResultTest
3333
*/
@@ -50,7 +50,7 @@ class ExecutionResult implements \JsonSerializable
5050
*
5151
* @api
5252
*
53-
* @var array<Error>
53+
* @var list<Error>
5454
*/
5555
public array $errors = [];
5656

@@ -79,7 +79,7 @@ class ExecutionResult implements \JsonSerializable
7979

8080
/**
8181
* @param array<string, mixed>|null $data
82-
* @param array<Error> $errors
82+
* @param list<Error> $errors
8383
* @param array<string, mixed> $extensions
8484
*/
8585
public function __construct(?array $data = null, array $errors = [], array $extensions = [])

src/Type/SchemaValidationContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
class SchemaValidationContext
4949
{
50-
/** @var array<int, Error> */
50+
/** @var list<Error> */
5151
private array $errors = [];
5252

5353
private Schema $schema;
@@ -60,7 +60,7 @@ public function __construct(Schema $schema)
6060
$this->inputObjectCircularRefs = new InputObjectCircularRefs($this);
6161
}
6262

63-
/** @return array<int, Error> */
63+
/** @return list<Error> */
6464
public function getErrors(): array
6565
{
6666
return $this->errors;

src/Validator/DocumentValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class DocumentValidator
9090
*
9191
* @throws \Exception
9292
*
93-
* @return array<int, Error>
93+
* @return list<Error>
9494
*
9595
* @api
9696
*/
@@ -263,7 +263,7 @@ public static function removeRule(ValidationRule $rule): void
263263
*
264264
* @throws \Exception
265265
*
266-
* @return array<int, Error>
266+
* @return list<Error>
267267
*/
268268
public static function validateSDL(
269269
DocumentNode $documentAST,

src/Validator/QueryValidationContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class QueryValidationContext implements ValidationContext
3636

3737
protected DocumentNode $ast;
3838

39-
/** @var array<int, Error> */
39+
/** @var list<Error> */
4040
protected array $errors = [];
4141

4242
private TypeInfo $typeInfo;
@@ -73,7 +73,7 @@ public function reportError(Error $error): void
7373
$this->errors[] = $error;
7474
}
7575

76-
/** @return array<int, Error> */
76+
/** @return list<Error> */
7777
public function getErrors(): array
7878
{
7979
return $this->errors;

src/Validator/ValidationContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface ValidationContext
1010
{
1111
public function reportError(Error $error): void;
1212

13-
/** @return array<int, Error> */
13+
/** @return list<Error> */
1414
public function getErrors(): array;
1515

1616
public function getDocument(): DocumentNode;

0 commit comments

Comments
 (0)