Skip to content

Commit 7d1da83

Browse files
authored
Merge pull request #1635 from webonyx/renovate/major-phpstan
chore(deps): update phpstan packages to v2 (major)
2 parents ed6b5cc + c515359 commit 7d1da83

38 files changed

+156
-90
lines changed

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"nyholm/psr7": "^1.5",
2424
"phpbench/phpbench": "^1.2",
2525
"phpstan/extension-installer": "^1.1",
26-
"phpstan/phpstan": "1.12.12",
27-
"phpstan/phpstan-phpunit": "1.4.1",
28-
"phpstan/phpstan-strict-rules": "1.6.1",
26+
"phpstan/phpstan": "2.1.8",
27+
"phpstan/phpstan-phpunit": "2.0.4",
28+
"phpstan/phpstan-strict-rules": "2.0.3",
2929
"phpunit/phpunit": "^9.5 || ^10.5.21 || ^11",
3030
"psr/http-message": "^1 || ^2",
3131
"react/http": "^1.6",
3232
"react/promise": "^2.0 || ^3.0",
33-
"rector/rector": "^1.0",
33+
"rector/rector": "^2.0",
3434
"symfony/polyfill-php81": "^1.23",
3535
"symfony/var-exporter": "^5 || ^6 || ^7",
3636
"thecodingmachine/safe": "^1.3 || ^2"

generate-class-reference.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
];
4040

4141
/**
42-
* @param ReflectionClass<object> $class
42+
* @param ReflectionClass<covariant object> $class
4343
* @param array{constants?: bool, props?: bool, methods?: bool} $options
4444
*
4545
* @throws ExceptionInterface

phpstan-baseline.neon

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Unable to resolve the template type TCloneable in call to method static method GraphQL\\\\Language\\\\AST\\\\Node\\:\\:cloneValue\\(\\)$#"
4+
message: '#^Unable to resolve the template type TCloneable in call to method static method GraphQL\\Language\\AST\\Node\:\:cloneValue\(\)$#'
5+
identifier: argument.templateType
56
count: 1
67
path: src/Language/AST/Node.php
78

89
-
9-
message: "#^Variable property access on TCloneable of TNode of GraphQL\\\\Language\\\\AST\\\\Node\\.$#"
10+
message: '#^Variable property access on TCloneable of TNode of GraphQL\\Language\\AST\\Node\.$#'
11+
identifier: property.dynamicName
1012
count: 1
1113
path: src/Language/AST/Node.php
1214

1315
-
14-
message: "#^Variable property access on GraphQL\\\\Language\\\\AST\\\\Node\\.$#"
16+
message: '#^Variable property access on GraphQL\\Language\\AST\\Node\.$#'
17+
identifier: property.dynamicName
1518
count: 1
1619
path: src/Language/Visitor.php
1720

1821
-
19-
message: "#^Variable property access on GraphQL\\\\Language\\\\AST\\\\Node\\|null\\.$#"
22+
message: '#^Variable property access on GraphQL\\Language\\AST\\Node\|null\.$#'
23+
identifier: property.dynamicName
2024
count: 1
2125
path: src/Language/Visitor.php
2226

2327
-
24-
message: "#^Parameter \\#1 \\$config of class GraphQL\\\\Type\\\\Definition\\\\Argument constructor expects array\\{name\\: string, type\\: \\(callable\\(\\)\\: \\(GraphQL\\\\Type\\\\Definition\\\\InputType&GraphQL\\\\Type\\\\Definition\\\\Type\\)\\)\\|\\(GraphQL\\\\Type\\\\Definition\\\\InputType&GraphQL\\\\Type\\\\Definition\\\\Type\\), defaultValue\\?\\: mixed, description\\?\\: string\\|null, deprecationReason\\?\\: string\\|null, astNode\\?\\: GraphQL\\\\Language\\\\AST\\\\InputValueDefinitionNode\\|null\\}, non\\-empty\\-array given\\.$#"
25-
count: 1
26-
path: src/Type/Definition/Argument.php
27-
28-
-
29-
message: "#^Property GraphQL\\\\Type\\\\Definition\\\\InterfaceType\\:\\:\\$interfaces \\(array\\<int, GraphQL\\\\Type\\\\Definition\\\\InterfaceType\\>\\) does not accept array\\<int, GraphQL\\\\Type\\\\Definition\\\\Type\\>\\.$#"
28+
message: '#^Property GraphQL\\Type\\Definition\\InterfaceType\:\:\$interfaces \(array\<int, GraphQL\\Type\\Definition\\InterfaceType\>\) does not accept array\<int, GraphQL\\Type\\Definition\\Type\>\.$#'
29+
identifier: assign.propertyType
3030
count: 1
3131
path: src/Type/Definition/InterfaceType.php
3232

3333
-
34-
message: "#^Unable to resolve the template type T in call to method static method GraphQL\\\\Type\\\\Schema\\:\\:resolveType\\(\\)$#"
34+
message: '#^Unable to resolve the template type T in call to method static method GraphQL\\Type\\Schema\:\:resolveType\(\)$#'
35+
identifier: argument.templateType
3536
count: 1
3637
path: src/Type/Definition/InterfaceType.php
3738

3839
-
39-
message: "#^Property GraphQL\\\\Type\\\\Definition\\\\ObjectType\\:\\:\\$interfaces \\(array\\<int, GraphQL\\\\Type\\\\Definition\\\\InterfaceType\\>\\) does not accept array\\<int, GraphQL\\\\Type\\\\Definition\\\\Type\\>\\.$#"
40+
message: '#^Property GraphQL\\Type\\Definition\\ObjectType\:\:\$interfaces \(array\<int, GraphQL\\Type\\Definition\\InterfaceType\>\) does not accept array\<int, GraphQL\\Type\\Definition\\Type\>\.$#'
41+
identifier: assign.propertyType
4042
count: 1
4143
path: src/Type/Definition/ObjectType.php
4244

4345
-
44-
message: "#^Unable to resolve the template type T in call to method static method GraphQL\\\\Type\\\\Schema\\:\\:resolveType\\(\\)$#"
46+
message: '#^Unable to resolve the template type T in call to method static method GraphQL\\Type\\Schema\:\:resolveType\(\)$#'
47+
identifier: argument.templateType
4548
count: 1
4649
path: src/Type/Definition/ObjectType.php
4750

4851
-
49-
message: "#^Method GraphQL\\\\Type\\\\Definition\\\\UnionType\\:\\:getTypes\\(\\) should return array\\<int, GraphQL\\\\Type\\\\Definition\\\\ObjectType\\> but returns array\\<int, GraphQL\\\\Type\\\\Definition\\\\Type\\>\\.$#"
52+
message: '#^Method GraphQL\\Type\\Definition\\UnionType\:\:getTypes\(\) should return array\<int, GraphQL\\Type\\Definition\\ObjectType\> but returns array\<int, GraphQL\\Type\\Definition\\Type\>\.$#'
53+
identifier: return.type
5054
count: 1
5155
path: src/Type/Definition/UnionType.php
5256

5357
-
54-
message: "#^Property GraphQL\\\\Type\\\\Definition\\\\UnionType\\:\\:\\$types \\(array\\<int, GraphQL\\\\Type\\\\Definition\\\\ObjectType\\>\\) does not accept array\\<int, GraphQL\\\\Type\\\\Definition\\\\Type\\>\\.$#"
58+
message: '#^Property GraphQL\\Type\\Definition\\UnionType\:\:\$types \(array\<int, GraphQL\\Type\\Definition\\ObjectType\>\) does not accept array\<int, GraphQL\\Type\\Definition\\Type\>\.$#'
59+
identifier: assign.propertyType
5560
count: 1
5661
path: src/Type/Definition/UnionType.php
5762

5863
-
59-
message: "#^Unable to resolve the template type T in call to method static method GraphQL\\\\Type\\\\Schema\\:\\:resolveType\\(\\)$#"
64+
message: '#^Unable to resolve the template type T in call to method static method GraphQL\\Type\\Schema\:\:resolveType\(\)$#'
65+
identifier: argument.templateType
6066
count: 1
6167
path: src/Type/Definition/UnionType.php
6268

6369
-
64-
message: "#^Method GraphQL\\\\Type\\\\Schema\\:\\:resolveType\\(\\) should return T of GraphQL\\\\Type\\\\Definition\\\\Type but returns \\(callable&GraphQL\\\\Type\\\\Definition\\\\Type\\)\\|T of GraphQL\\\\Type\\\\Definition\\\\Type\\.$#"
70+
message: '#^Method GraphQL\\Type\\Schema\:\:resolveType\(\) should return T of GraphQL\\Type\\Definition\\Type but returns \(callable&GraphQL\\Type\\Definition\\Type\)\|T of GraphQL\\Type\\Definition\\Type\.$#'
71+
identifier: return.type
6572
count: 1
6673
path: src/Type/Schema.php
6774

6875
-
69-
message: "#^Variable property access on GraphQL\\\\Language\\\\AST\\\\ArgumentNode\\|GraphQL\\\\Language\\\\AST\\\\BooleanValueNode\\|GraphQL\\\\Language\\\\AST\\\\DirectiveDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\DirectiveNode\\|GraphQL\\\\Language\\\\AST\\\\DocumentNode\\|GraphQL\\\\Language\\\\AST\\\\EnumTypeDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\EnumTypeExtensionNode\\|GraphQL\\\\Language\\\\AST\\\\EnumValueDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\EnumValueNode\\|GraphQL\\\\Language\\\\AST\\\\FieldDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\FieldNode\\|GraphQL\\\\Language\\\\AST\\\\FloatValueNode\\|GraphQL\\\\Language\\\\AST\\\\FragmentDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\FragmentSpreadNode\\|GraphQL\\\\Language\\\\AST\\\\InlineFragmentNode\\|GraphQL\\\\Language\\\\AST\\\\InputObjectTypeDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\InputObjectTypeExtensionNode\\|GraphQL\\\\Language\\\\AST\\\\InputValueDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\InterfaceTypeDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\InterfaceTypeExtensionNode\\|GraphQL\\\\Language\\\\AST\\\\IntValueNode\\|GraphQL\\\\Language\\\\AST\\\\ListTypeNode\\|GraphQL\\\\Language\\\\AST\\\\ListValueNode\\|GraphQL\\\\Language\\\\AST\\\\NamedTypeNode\\|GraphQL\\\\Language\\\\AST\\\\NameNode\\|GraphQL\\\\Language\\\\AST\\\\NonNullTypeNode\\|GraphQL\\\\Language\\\\AST\\\\NullValueNode\\|GraphQL\\\\Language\\\\AST\\\\ObjectFieldNode\\|GraphQL\\\\Language\\\\AST\\\\ObjectTypeDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\ObjectTypeExtensionNode\\|GraphQL\\\\Language\\\\AST\\\\ObjectValueNode\\|GraphQL\\\\Language\\\\AST\\\\OperationDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\OperationTypeDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\ScalarTypeDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\ScalarTypeExtensionNode\\|GraphQL\\\\Language\\\\AST\\\\SchemaDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\SelectionSetNode\\|GraphQL\\\\Language\\\\AST\\\\StringValueNode\\|GraphQL\\\\Language\\\\AST\\\\UnionTypeDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\UnionTypeExtensionNode\\|GraphQL\\\\Language\\\\AST\\\\VariableDefinitionNode\\|GraphQL\\\\Language\\\\AST\\\\VariableNode\\.$#"
76+
message: '#^Variable property access on GraphQL\\Language\\AST\\ArgumentNode\|GraphQL\\Language\\AST\\BooleanValueNode\|GraphQL\\Language\\AST\\DirectiveDefinitionNode\|GraphQL\\Language\\AST\\DirectiveNode\|GraphQL\\Language\\AST\\DocumentNode\|GraphQL\\Language\\AST\\EnumTypeDefinitionNode\|GraphQL\\Language\\AST\\EnumTypeExtensionNode\|GraphQL\\Language\\AST\\EnumValueDefinitionNode\|GraphQL\\Language\\AST\\EnumValueNode\|GraphQL\\Language\\AST\\FieldDefinitionNode\|GraphQL\\Language\\AST\\FieldNode\|GraphQL\\Language\\AST\\FloatValueNode\|GraphQL\\Language\\AST\\FragmentDefinitionNode\|GraphQL\\Language\\AST\\FragmentSpreadNode\|GraphQL\\Language\\AST\\InlineFragmentNode\|GraphQL\\Language\\AST\\InputObjectTypeDefinitionNode\|GraphQL\\Language\\AST\\InputObjectTypeExtensionNode\|GraphQL\\Language\\AST\\InputValueDefinitionNode\|GraphQL\\Language\\AST\\InterfaceTypeDefinitionNode\|GraphQL\\Language\\AST\\InterfaceTypeExtensionNode\|GraphQL\\Language\\AST\\IntValueNode\|GraphQL\\Language\\AST\\ListTypeNode\|GraphQL\\Language\\AST\\ListValueNode\|GraphQL\\Language\\AST\\NamedTypeNode\|GraphQL\\Language\\AST\\NameNode\|GraphQL\\Language\\AST\\NonNullTypeNode\|GraphQL\\Language\\AST\\NullValueNode\|GraphQL\\Language\\AST\\ObjectFieldNode\|GraphQL\\Language\\AST\\ObjectTypeDefinitionNode\|GraphQL\\Language\\AST\\ObjectTypeExtensionNode\|GraphQL\\Language\\AST\\ObjectValueNode\|GraphQL\\Language\\AST\\OperationDefinitionNode\|GraphQL\\Language\\AST\\OperationTypeDefinitionNode\|GraphQL\\Language\\AST\\ScalarTypeDefinitionNode\|GraphQL\\Language\\AST\\ScalarTypeExtensionNode\|GraphQL\\Language\\AST\\SchemaDefinitionNode\|GraphQL\\Language\\AST\\SelectionSetNode\|GraphQL\\Language\\AST\\StringValueNode\|GraphQL\\Language\\AST\\UnionTypeDefinitionNode\|GraphQL\\Language\\AST\\UnionTypeExtensionNode\|GraphQL\\Language\\AST\\VariableDefinitionNode\|GraphQL\\Language\\AST\\VariableNode\.$#'
77+
identifier: property.dynamicName
7078
count: 1
7179
path: src/Utils/AST.php
7280

7381
-
74-
message: "#^Variable property access on mixed\\.$#"
82+
message: '#^Variable property access on mixed\.$#'
83+
identifier: property.dynamicName
7584
count: 1
7685
path: src/Utils/AST.php
7786

7887
-
79-
message: "#^Method GraphQL\\\\Validator\\\\Rules\\\\KnownDirectives\\:\\:getDirectiveLocationForASTPath\\(\\) has parameter \\$ancestors with generic class GraphQL\\\\Language\\\\AST\\\\NodeList but does not specify its types\\: T$#"
88+
message: '#^Method GraphQL\\Validator\\Rules\\KnownDirectives\:\:getDirectiveLocationForASTPath\(\) has parameter \$ancestors with generic class GraphQL\\Language\\AST\\NodeList but does not specify its types\: T$#'
89+
identifier: missingType.generics
8090
count: 1
8191
path: src/Validator/Rules/KnownDirectives.php
82-
83-
-
84-
message: "#^Method GraphQL\\\\Validator\\\\Rules\\\\OverlappingFieldsCanBeMerged\\:\\:getFieldsAndFragmentNames\\(\\) should return array\\{array\\<string, array\\<int, array\\{GraphQL\\\\Type\\\\Definition\\\\Type, GraphQL\\\\Language\\\\AST\\\\FieldNode, GraphQL\\\\Type\\\\Definition\\\\FieldDefinition\\|null\\}\\>\\>, array\\<int, string\\>\\} but returns array\\{mixed, array\\<int, int\\|string\\>\\}\\.$#"
85-
count: 1
86-
path: src/Validator/Rules/OverlappingFieldsCanBeMerged.php
87-
88-
-
89-
message: "#^SplObjectStorage\\<GraphQL\\\\Language\\\\AST\\\\SelectionSetNode, array\\{array\\<string, array\\<int, array\\{GraphQL\\\\Type\\\\Definition\\\\Type, GraphQL\\\\Language\\\\AST\\\\FieldNode, GraphQL\\\\Type\\\\Definition\\\\FieldDefinition\\|null\\}\\>\\>, array\\<int, string\\>\\}\\> does not accept array\\<int, mixed\\>\\.$#"
90-
count: 1
91-
path: src/Validator/Rules/OverlappingFieldsCanBeMerged.php

phpstan/include-by-php-version.php

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
if (version_compare($phpversion, '8.2', '>=')) {
77
$includes[] = __DIR__ . '/php-at-least-8.2.neon';
88
}
9+
if (version_compare($phpversion, '8.4', '<')) {
10+
$includes[] = __DIR__ . '/php-below-8.4.neon';
11+
}
12+
if (version_compare($phpversion, '8.2', '<')) {
13+
$includes[] = __DIR__ . '/php-below-8.2.neon';
14+
}
915
if (version_compare($phpversion, '8.1', '<')) {
1016
$includes[] = __DIR__ . '/php-below-8.1.neon';
1117
}

phpstan/php-below-8.2.neon

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
identifier: function.alreadyNarrowedType
5+
count: 2
6+
path: ../src/Type/Definition/QueryPlan.php
7+
8+
-
9+
identifier: function.alreadyNarrowedType
10+
count: 2
11+
path: ../src/Utils/TypeInfo.php

phpstan/php-below-8.4.neon

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Call\-site variance of covariant object in generic type ReflectionClass\<covariant object\> in PHPDoc tag @param for parameter \$class is redundant, template type T of object of class ReflectionClass has the same variance\.$#'
5+
identifier: generics.callSiteVarianceRedundant
6+
count: 1
7+
path: ../generate-class-reference.php

src/Error/Error.php

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function __construct(
9393

9494
// Compute list of blame nodes.
9595
if ($nodes instanceof \Traversable) {
96+
/** @phpstan-ignore arrayFilter.strict */
9697
$this->nodes = array_filter(\iterator_to_array($nodes));
9798
} elseif (\is_array($nodes)) {
9899
$this->nodes = array_filter($nodes);

src/Executor/ExecutionContext.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ExecutionContext
4949
*/
5050
public $argsMapper;
5151

52-
/** @var array<int, Error> */
52+
/** @var list<Error> */
5353
public array $errors;
5454

5555
public PromiseAdapter $promiseAdapter;
@@ -59,7 +59,7 @@ class ExecutionContext
5959
* @param mixed $rootValue
6060
* @param mixed $contextValue
6161
* @param array<string, mixed> $variableValues
62-
* @param array<int, Error> $errors
62+
* @param list<Error> $errors
6363
*
6464
* @phpstan-param FieldResolver $fieldResolver
6565
*/

src/Executor/ExecutionResult.php

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function toArray(int $debug = DebugFlag::NONE): array
161161
$errorsHandler = $this->errorsHandler
162162
?? static fn (array $errors, callable $formatter): array => \array_map($formatter, $errors);
163163

164+
/** @phpstan-var SerializableErrors */
164165
$handledErrors = $errorsHandler(
165166
$this->errors,
166167
FormattedError::prepareFormatter($this->errorFormatter, $debug)

src/Executor/Promise/Adapter/AmpPromiseAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function all(iterable $promisesOrValues): Promise
126126

127127
/**
128128
* @template TArgument
129-
* @template TResult
129+
* @template TResult of AmpPromise<mixed>
130130
*
131131
* @param Deferred<TResult> $deferred
132132
* @param callable(TArgument): TResult $callback

src/Executor/ReferenceExecutor.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function doExecute(): Promise
150150
*
151151
* @throws \Exception
152152
*
153-
* @return ExecutionContext|array<int, Error>
153+
* @return ExecutionContext|list<Error>
154154
*/
155155
protected static function buildExecutionContext(
156156
Schema $schema,
@@ -163,7 +163,7 @@ protected static function buildExecutionContext(
163163
callable $argsMapper,
164164
PromiseAdapter $promiseAdapter
165165
) {
166-
/** @var array<int, Error> $errors */
166+
/** @var list<Error> $errors */
167167
$errors = [];
168168

169169
/** @var array<string, FragmentDefinitionNode> $fragments */

src/Language/AST/Node.php

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ protected static function cloneValue($value)
7979
}
8080

8181
if ($value instanceof NodeList) {
82+
/**
83+
* @phpstan-var TCloneable
84+
*
85+
* @phpstan-ignore varTag.nativeType (PHPStan is strict about template types and sees NodeList<TNode> as potentially different from TCloneable)
86+
*/
8287
return $value->cloneDeep();
8388
}
8489

src/Language/AST/NodeList.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ public function reindex(): void
145145
*/
146146
public function cloneDeep(): self
147147
{
148-
/** @var static<T> $cloned */
149-
$cloned = new static([]);
148+
/** @var array<T> $empty */
149+
$empty = [];
150+
$cloned = new static($empty);
150151
foreach ($this->getIterator() as $key => $node) {
151152
$cloned[$key] = $node->cloneDeep();
152153
}

src/Language/Printer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,6 @@ protected function indent(string $string): string
531531
/** @param array<string|null> $parts */
532532
protected function join(array $parts, string $separator = ''): string
533533
{
534-
return \implode($separator, \array_filter($parts));
534+
return \implode($separator, \array_filter($parts, static fn (?string $part) => $part !== '' && $part !== null));
535535
}
536536
}

src/Language/Visitor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public static function visitWithTypeInfo(TypeInfo $typeInfo, array $visitor): ar
478478
/**
479479
* @phpstan-param VisitorArray $visitor
480480
*
481-
* @return callable(Node $node, string $key, Node|NodeList $parent, array<int, int|string $path, array<int, Node|NodeList> $ancestors): VisitorOperation|Node|null
481+
* @return (callable(Node $node, string $key, Node|NodeList<Node>|null $parent, array<int, int|string> $path, array<int, Node|NodeList<Node>> $ancestors): (VisitorOperation|Node|null))|(callable(Node): (VisitorOperation|void|false|null))|null
482482
*/
483483
protected static function extractVisitFn(array $visitor, string $kind, bool $isLeaving): ?callable
484484
{

src/Type/Definition/Argument.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ public static function listFromConfig(iterable $config): array
7373
$argConfig = ['type' => $argConfig];
7474
}
7575

76-
$list[] = new self($argConfig + ['name' => $name]);
76+
/** @phpstan-var ArgumentConfig $argConfigWithName */
77+
$argConfigWithName = $argConfig + ['name' => $name];
78+
79+
$list[] = new self($argConfigWithName);
7780
}
7881

7982
return $list;

src/Type/Definition/QueryPlan.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private function analyzeQueryPlan(ObjectType $parentType, iterable $fieldNodes):
142142
if ($this->groupImplementorFields) {
143143
$this->queryPlan = ['fields' => $queryPlan];
144144

145-
if ($implementors) {
145+
if ($implementors !== []) {
146146
$this->queryPlan['implementors'] = $implementors;
147147
}
148148
} else {
@@ -188,7 +188,7 @@ private function analyzeSelectionSet(SelectionSetNode $selectionSet, Type $paren
188188
'fields' => $subfields,
189189
'args' => Values::getArgumentValues($type, $selection, $this->variableValues),
190190
];
191-
if ($this->groupImplementorFields && $subImplementors) {
191+
if ($this->groupImplementorFields && $subImplementors !== []) {
192192
$fields[$fieldName]['implementors'] = $subImplementors;
193193
}
194194
} elseif ($selection instanceof FragmentSpreadNode) {
@@ -256,10 +256,13 @@ private function analyzeSubFields(Type $type, SelectionSetNode $selectionSet, ar
256256
private function mergeFields(Type $parentType, Type $type, array $fields, array $subfields, array &$implementors): array
257257
{
258258
if ($this->groupImplementorFields && $parentType instanceof AbstractType && ! $type instanceof AbstractType) {
259-
$implementors[$type->name] = [
259+
$name = $type->name;
260+
assert(\is_string($name));
261+
262+
$implementors[$name] = [
260263
'type' => $type,
261264
'fields' => $this->arrayMergeDeep(
262-
$implementors[$type->name]['fields'] ?? [],
265+
$implementors[$name]['fields'] ?? [],
263266
\array_diff_key($subfields, $fields)
264267
),
265268
];

0 commit comments

Comments
 (0)