Skip to content

Commit

Permalink
Change Path from array to list
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Jun 10, 2024
1 parent 313e2dc commit 8a4113b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
3 changes: 1 addition & 2 deletions docs/class-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ Passed as 4th argument to every field resolver. See [docs on field resolving (da
@phpstan-import-type QueryPlanOptions from QueryPlan

@phpstan-type Path array<int, string|int>
@phpstan-type UnaliasedPath list<string|int>

### GraphQL\Type\Definition\ResolveInfo Props

Expand Down Expand Up @@ -369,7 +368,7 @@ public $path;
*
* @var list<string|int>
*
* @phpstan-var UnaliasedPath
* @phpstan-var Path
*/
public $unaliasedPath;

Expand Down
12 changes: 6 additions & 6 deletions src/Error/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Error extends \Exception implements \JsonSerializable, ClientAware, Provid
* corresponds to this error. Only included for errors during execution.
* When fields are aliased, the path includes aliases.
*
* @var array<int, int|string>|null
* @var list<int|string>|null
*/
public ?array $path;

Expand Down Expand Up @@ -75,9 +75,9 @@ class Error extends \Exception implements \JsonSerializable, ClientAware, Provid
/**
* @param iterable<array-key, Node|null>|Node|null $nodes
* @param array<int, int>|null $positions
* @param array<int, int|string>|null $path
* @param list<int|string>|null $path
* @param array<string, mixed>|null $extensions
* @param list<int|string>|null $unaliasedPath
* @param list<int|string>|null $unaliasedPath
*/
public function __construct(
string $message = '',
Expand Down Expand Up @@ -127,8 +127,8 @@ public function __construct(
*
* @param mixed $error
* @param iterable<Node>|Node|null $nodes
* @param array<int, int|string>|null $path
* @param list<int|string>|null $unaliasedPath
* @param list<int|string>|null $path
* @param list<int|string>|null $unaliasedPath
*/
public static function createLocatedError($error, $nodes = null, ?array $path = null, ?array $unaliasedPath = null): Error
{
Expand Down Expand Up @@ -269,7 +269,7 @@ public function getNodes(): ?array
* Returns an array describing the path from the root value to the field which produced this error.
* Only included for execution errors. When fields are aliased, the path includes aliases.
*
* @return array<int, int|string>|null
* @return list<int|string>|null
*
* @api
*/
Expand Down
23 changes: 11 additions & 12 deletions src/Executor/ReferenceExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
/**
* @phpstan-import-type FieldResolver from Executor
* @phpstan-import-type Path from ResolveInfo
* @phpstan-import-type UnaliasedPath from ResolveInfo
*
* @phpstan-type Fields \ArrayObject<string, \ArrayObject<int, FieldNode>>
*/
Expand Down Expand Up @@ -523,7 +522,7 @@ protected function doesFragmentConditionMatch(Node $fragment, ObjectType $type):
* Implements the "Evaluating selection sets" section of the spec for "write" mode.
*
* @param mixed $rootValue
* @param array<string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param mixed $contextValue
*
Expand Down Expand Up @@ -587,12 +586,12 @@ function ($results, $responseName) use ($contextValue, $path, $unaliasedPath, $p
* serialize scalars, or execute the sub-selection-set for objects.
*
* @param mixed $rootValue
* @param array<int, string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param mixed $contextValue
*
* @phpstan-param Path $path
* @phpstan-param UnaliasedPath $unaliasedPath
* @phpstan-param Path $unaliasedPath
*
* @param \ArrayObject<int, FieldNode> $fieldNodes
*
Expand Down Expand Up @@ -736,12 +735,12 @@ protected function resolveFieldValueOrError(
* in the execution context.
*
* @param \ArrayObject<int, FieldNode> $fieldNodes
* @param array<string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param mixed $contextValue
*
* @phpstan-param Path $path
* @phpstan-param UnaliasedPath $unaliasedPath
* @phpstan-param Path $unaliasedPath
*
* @param mixed $result
*
Expand Down Expand Up @@ -788,7 +787,7 @@ protected function completeValueCatchingError(
/**
* @param mixed $rawError
* @param \ArrayObject<int, FieldNode> $fieldNodes
* @param array<int, string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
*
* @throws Error
Expand Down Expand Up @@ -835,7 +834,7 @@ protected function handleFieldError($rawError, \ArrayObject $fieldNodes, array $
* value by evaluating all sub-selections.
*
* @param \ArrayObject<int, FieldNode> $fieldNodes
* @param array<string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param mixed $result
* @param mixed $contextValue
Expand Down Expand Up @@ -1053,7 +1052,7 @@ protected function completeLeafValue(LeafType $returnType, &$result)
*
* @param AbstractType&Type $returnType
* @param \ArrayObject<int, FieldNode> $fieldNodes
* @param array<string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param array<mixed> $result
* @param mixed $contextValue
Expand Down Expand Up @@ -1187,7 +1186,7 @@ protected function defaultTypeResolver($value, $contextValue, ResolveInfo $info,
* Complete an Object value by executing all sub-selections.
*
* @param \ArrayObject<int, FieldNode> $fieldNodes
* @param array<string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param mixed $result
* @param mixed $contextValue
Expand Down Expand Up @@ -1271,7 +1270,7 @@ protected function invalidReturnTypeError(

/**
* @param \ArrayObject<int, FieldNode> $fieldNodes
* @param array<string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param mixed $result
* @param mixed $contextValue
Expand Down Expand Up @@ -1335,7 +1334,7 @@ protected function collectSubFields(ObjectType $returnType, \ArrayObject $fieldN
* Implements the "Evaluating selection sets" section of the spec for "read" mode.
*
* @param mixed $rootValue
* @param array<string|int> $path
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
* @param mixed $contextValue
*
Expand Down
13 changes: 6 additions & 7 deletions src/Type/Definition/ResolveInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
*
* @phpstan-import-type QueryPlanOptions from QueryPlan
*
* @phpstan-type Path array<int, string|int>
* @phpstan-type UnaliasedPath list<string|int>
* @phpstan-type Path list<string|int>
*/
class ResolveInfo
{
Expand Down Expand Up @@ -66,7 +65,7 @@ class ResolveInfo
*
* @api
*
* @var array<int, string|int>
* @var list<string|int>
*
* @phpstan-var Path
*/
Expand All @@ -79,7 +78,7 @@ class ResolveInfo
*
* @var list<string|int>
*
* @phpstan-var UnaliasedPath
* @phpstan-var Path
*/
public array $unaliasedPath;

Expand Down Expand Up @@ -126,11 +125,11 @@ class ResolveInfo

/**
* @param \ArrayObject<int, FieldNode> $fieldNodes
* @param array<int, string|int> $path
* @param array<int, string|int> $unaliasedPath
* @param list<string|int> $path
* @param list<string|int> $unaliasedPath
*
* @phpstan-param Path $path
* @phpstan-param UnaliasedPath $unaliasedPath
* @phpstan-param Path $unaliasedPath
*
* @param array<string, FragmentDefinitionNode> $fragments
* @param mixed|null $rootValue
Expand Down

0 comments on commit 8a4113b

Please sign in to comment.