Skip to content

Commit

Permalink
Narrow errors type to list
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored Sep 26, 2024
1 parent 87f9564 commit 9e675b5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions docs/class-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1424,14 +1424,14 @@ locations?: array<int, array{line: int, column: int}>,
path?: array<int, int|string>,
extensions?: array<string, mixed>
}
@phpstan-type SerializableErrors array<int, SerializableError>
@phpstan-type SerializableErrors list<SerializableError>
@phpstan-type SerializableResult array{
data?: array<string, mixed>,
errors?: SerializableErrors,
extensions?: array<string, mixed>
}
@phpstan-type ErrorFormatter callable(\Throwable): SerializableError
@phpstan-type ErrorsHandler callable(array<Error> $errors, ErrorFormatter $formatter): SerializableErrors
@phpstan-type ErrorsHandler callable(list<Error> $errors, ErrorFormatter $formatter): SerializableErrors

@see \GraphQL\Tests\Executor\ExecutionResultTest

Expand All @@ -1455,7 +1455,7 @@ public $data;
*
* @api
*
* @var array<Error>
* @var list<Error>
*/
public $errors;

Expand Down Expand Up @@ -1642,7 +1642,7 @@ will be created from the provided schema.
*
* @throws \Exception
*
* @return array<int, Error>
* @return list<Error>
*
* @api
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Executor/ExecutionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
* path?: array<int, int|string>,
* extensions?: array<string, mixed>
* }
* @phpstan-type SerializableErrors array<int, SerializableError>
* @phpstan-type SerializableErrors list<SerializableError>
* @phpstan-type SerializableResult array{
* data?: array<string, mixed>,
* errors?: SerializableErrors,
* extensions?: array<string, mixed>
* }
* @phpstan-type ErrorFormatter callable(\Throwable): SerializableError
* @phpstan-type ErrorsHandler callable(array<Error> $errors, ErrorFormatter $formatter): SerializableErrors
* @phpstan-type ErrorsHandler callable(list<Error> $errors, ErrorFormatter $formatter): SerializableErrors
*
* @see \GraphQL\Tests\Executor\ExecutionResultTest
*/
Expand All @@ -50,7 +50,7 @@ class ExecutionResult implements \JsonSerializable
*
* @api
*
* @var array<Error>
* @var list<Error>
*/
public array $errors = [];

Expand Down Expand Up @@ -79,7 +79,7 @@ class ExecutionResult implements \JsonSerializable

/**
* @param array<string, mixed>|null $data
* @param array<Error> $errors
* @param list<Error> $errors
* @param array<string, mixed> $extensions
*/
public function __construct(?array $data = null, array $errors = [], array $extensions = [])
Expand Down
4 changes: 2 additions & 2 deletions src/Type/SchemaValidationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

class SchemaValidationContext
{
/** @var array<int, Error> */
/** @var list<Error> */
private array $errors = [];

private Schema $schema;
Expand All @@ -60,7 +60,7 @@ public function __construct(Schema $schema)
$this->inputObjectCircularRefs = new InputObjectCircularRefs($this);
}

/** @return array<int, Error> */
/** @return list<Error> */
public function getErrors(): array
{
return $this->errors;
Expand Down
4 changes: 2 additions & 2 deletions src/Validator/DocumentValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class DocumentValidator
*
* @throws \Exception
*
* @return array<int, Error>
* @return list<Error>
*
* @api
*/
Expand Down Expand Up @@ -263,7 +263,7 @@ public static function removeRule(ValidationRule $rule): void
*
* @throws \Exception
*
* @return array<int, Error>
* @return list<Error>
*/
public static function validateSDL(
DocumentNode $documentAST,
Expand Down
4 changes: 2 additions & 2 deletions src/Validator/QueryValidationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class QueryValidationContext implements ValidationContext

protected DocumentNode $ast;

/** @var array<int, Error> */
/** @var list<Error> */
protected array $errors = [];

private TypeInfo $typeInfo;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function reportError(Error $error): void
$this->errors[] = $error;
}

/** @return array<int, Error> */
/** @return list<Error> */
public function getErrors(): array
{
return $this->errors;
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/ValidationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface ValidationContext
{
public function reportError(Error $error): void;

/** @return array<int, Error> */
/** @return list<Error> */
public function getErrors(): array;

public function getDocument(): DocumentNode;
Expand Down

0 comments on commit 9e675b5

Please sign in to comment.