Skip to content

Commit 3c53cab

Browse files
committed
Generalize handle of Field type
1 parent 2612985 commit 3c53cab

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ parameters:
66
count: 1
77
path: src/GraphQL.php
88

9-
-
10-
rawMessage: 'Cannot access offset ''name'' on array<string, mixed>|Rebing\GraphQL\Support\Field.'
11-
identifier: offsetAccess.nonOffsetAccessible
12-
count: 2
13-
path: src/GraphQL.php
14-
159
-
1610
rawMessage: Instanceof between Error and Error will always evaluate to true.
1711
identifier: instanceof.alwaysTrue
@@ -25,7 +19,7 @@ parameters:
2519
path: src/GraphQL.php
2620

2721
-
28-
rawMessage: 'Parameter #1 $config of class GraphQL\Type\Definition\ObjectType constructor expects array{name?: string|null, description?: string|null, resolveField?: (callable(mixed, array<string, mixed>, mixed, GraphQL\Type\Definition\ResolveInfo): mixed)|null, argsMapper?: (callable(array<string, mixed>, GraphQL\Type\Definition\FieldDefinition, GraphQL\Language\AST\FieldNode, mixed): mixed)|null, fields: (callable(): iterable)|iterable, interfaces?: (callable(): iterable<callable(): GraphQL\Type\Definition\InterfaceType|GraphQL\Type\Definition\InterfaceType>)|iterable<(callable(): GraphQL\Type\Definition\InterfaceType)|GraphQL\Type\Definition\InterfaceType>, isTypeOf?: (callable(mixed, mixed, GraphQL\Type\Definition\ResolveInfo): (bool|GraphQL\Deferred|null))|null, astNode?: GraphQL\Language\AST\ObjectTypeDefinitionNode|null, ...}, non-empty-array<string, array<non-empty-array<string, mixed>|(ArrayAccess&Rebing\GraphQL\Support\Field)>|string> given.'
22+
rawMessage: 'Parameter #1 $config of class GraphQL\Type\Definition\ObjectType constructor expects array{name?: string|null, description?: string|null, resolveField?: (callable(mixed, array<string, mixed>, mixed, GraphQL\Type\Definition\ResolveInfo): mixed)|null, argsMapper?: (callable(array<string, mixed>, GraphQL\Type\Definition\FieldDefinition, GraphQL\Language\AST\FieldNode, mixed): mixed)|null, fields: (callable(): iterable)|iterable, interfaces?: (callable(): iterable<callable(): GraphQL\Type\Definition\InterfaceType|GraphQL\Type\Definition\InterfaceType>)|iterable<(callable(): GraphQL\Type\Definition\InterfaceType)|GraphQL\Type\Definition\InterfaceType>, isTypeOf?: (callable(mixed, mixed, GraphQL\Type\Definition\ResolveInfo): (bool|GraphQL\Deferred|null))|null, astNode?: GraphQL\Language\AST\ObjectTypeDefinitionNode|null, ...}, non-empty-array<string, array|string> given.'
2923
identifier: argument.type
3024
count: 1
3125
path: src/GraphQL.php

src/GraphQL.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,8 @@ protected function buildObjectTypeFromFields(array $fields, array $opts = []): O
363363
foreach ($fields as $name => $field) {
364364
if (\is_string($field)) {
365365
$field = $this->app->make($field);
366-
/** @var Field $field */
367-
$field = $field->toArray();
368-
} elseif ($field instanceof Field) {
366+
}
367+
if ($field instanceof Field) {
369368
$field = $field->toArray();
370369
}
371370
$name = is_numeric($name) ? $field['name'] : $name;

0 commit comments

Comments
 (0)