44
55namespace SimPod \GraphQLUtils \Builder ;
66
7- use GraphQL \Type \Definition \ResolveInfo ;
8- use GraphQL \Type \Definition \Type ;
9-
7+ use GraphQL \Executor \Executor ;
8+ use GraphQL \Type \Definition \Argument ;
9+ use GraphQL \Type \Definition \FieldDefinition ;
10+
11+ /**
12+ * @see Executor
13+ * @see FieldDefinition
14+ * @see Argument
15+ *
16+ * @psalm-import-type FieldResolver from Executor
17+ * @psalm-import-type FieldDefinitionConfig from FieldDefinition
18+ * @psalm-import-type FieldType from FieldDefinition
19+ * @psalm-import-type ArgumentListConfig from Argument
20+ * @psalm-import-type ArgumentType from Argument
21+ */
1022class FieldBuilder
1123{
1224 private string $ name ;
1325
14- private Type $ type ;
26+ /** @psalm-var FieldType */
27+ private mixed $ type ;
1528
1629 private string |null $ description = null ;
1730
1831 private string |null $ deprecationReason = null ;
1932
20- /** @psalm-var callable(mixed, array<mixed>, mixed, ResolveInfo) : mixed |null */
33+ /** @psalm-var FieldResolver |null */
2134 private $ resolve ;
2235
23- /** @psalm-var array<string, array<string, mixed>> |null */
36+ /** @psalm-var (ArgumentListConfig& array) |null */
2437 private array |null $ args = null ;
2538
26- final private function __construct (string $ name , Type $ type )
39+ /**
40+ * @psalm-param FieldType $type
41+ */
42+ final private function __construct (string $ name , $ type )
2743 {
2844 $ this ->name = $ name ;
2945 $ this ->type = $ type ;
3046 }
3147
3248 /**
49+ * @psalm-param FieldType $type
50+ *
3351 * @return static
3452 */
35- public static function create (string $ name , Type $ type ): self
53+ public static function create (string $ name , $ type ): self
3654 {
3755 return new static ($ name , $ type );
3856 }
@@ -48,9 +66,11 @@ public function setDescription(string $description): self
4866 }
4967
5068 /**
69+ * @psalm-param ArgumentType $type
70+ *
5171 * @return $this
5272 */
53- public function addArgument (string $ name , Type $ type , ?string $ description = null , mixed $ defaultValue = null ): self
73+ public function addArgument (string $ name , $ type , ?string $ description = null , mixed $ defaultValue = null ): self
5474 {
5575 if ($ this ->args === null ) {
5676 $ this ->args = [];
@@ -63,6 +83,7 @@ public function addArgument(string $name, Type $type, ?string $description = nul
6383 }
6484
6585 if ($ defaultValue !== null ) {
86+ /** @psalm-suppress MixedAssignment */
6687 $ value ['defaultValue ' ] = $ defaultValue ;
6788 }
6889
@@ -72,9 +93,7 @@ public function addArgument(string $name, Type $type, ?string $description = nul
7293 }
7394
7495 /**
75- * @see ResolveInfo
76- *
77- * @param callable(mixed, array<mixed>, mixed, ResolveInfo) : mixed $resolver
96+ * @psalm-param FieldResolver $resolver
7897 *
7998 * @return $this
8099 */
@@ -96,7 +115,7 @@ public function setDeprecationReason(string $reason): self
96115 }
97116
98117 /**
99- * @return array<string, mixed>
118+ * @psalm- return FieldDefinitionConfig
100119 */
101120 public function build (): array
102121 {
0 commit comments