@@ -12,7 +12,7 @@ |
||
12 | 12 | * @var array |
13 | 13 | */ |
14 | 14 | protected $provides = [ |
15 | - CacheInterface::class, |
|
15 | + CacheInterface::class, |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | /** |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | * @inheritdoc |
46 | 46 | */ |
47 | 47 | public function extend( |
48 | - SchemaInterface $schema, |
|
49 | - DocumentNode $document, |
|
48 | + SchemaInterface $schema, |
|
49 | + DocumentNode $document, |
|
50 | 50 | ?ResolverRegistryInterface $resolverRegistry = null, |
51 | - array $options = [] |
|
51 | + array $options = [] |
|
52 | 52 | ): SchemaInterface { |
53 | 53 | $context = $this->createContext($schema, $document, $resolverRegistry); |
54 | 54 | |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | return newSchema([ |
62 | - 'query' => $context->getExtendedQueryType(), |
|
63 | - 'mutation' => $context->getExtendedMutationType(), |
|
64 | - 'subscription' => $context->getExtendedSubscriptionType(), |
|
65 | - 'types' => $context->getExtendedTypes(), |
|
66 | - 'directives' => $context->getExtendedDirectives(), |
|
67 | - 'astNode' => $schema->getAstNode(), |
|
62 | + 'query' => $context->getExtendedQueryType(), |
|
63 | + 'mutation' => $context->getExtendedMutationType(), |
|
64 | + 'subscription' => $context->getExtendedSubscriptionType(), |
|
65 | + 'types' => $context->getExtendedTypes(), |
|
66 | + 'directives' => $context->getExtendedDirectives(), |
|
67 | + 'astNode' => $schema->getAstNode(), |
|
68 | 68 | ]); |
69 | 69 | } |
70 | 70 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @inheritdoc |
73 | 73 | */ |
74 | 74 | public function createContext( |
75 | - SchemaInterface $schema, |
|
76 | - DocumentNode $document, |
|
75 | + SchemaInterface $schema, |
|
76 | + DocumentNode $document, |
|
77 | 77 | ?ResolverRegistryInterface $resolverRegistry |
78 | 78 | ): ExtensionContextInterface { |
79 | 79 | $info = $this->createInfo($schema, $document); |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | $context = new ExtensionContext($info); |
84 | 84 | |
85 | 85 | $definitionBuilder = new DefinitionBuilder( |
86 | - $info->getTypeDefinitionMap(), |
|
87 | - $resolverRegistry, |
|
88 | - [$context, 'resolveType'], |
|
89 | - $this->cache |
|
86 | + $info->getTypeDefinitionMap(), |
|
87 | + $resolverRegistry, |
|
88 | + [$context, 'resolveType'], |
|
89 | + $this->cache |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | return $context->setDefinitionBuilder($definitionBuilder); |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @throws ExtensionException |
101 | 101 | */ |
102 | 102 | protected function createInfo( |
103 | - SchemaInterface $schema, |
|
104 | - DocumentNode $document |
|
103 | + SchemaInterface $schema, |
|
104 | + DocumentNode $document |
|
105 | 105 | ): ExtendInfo { |
106 | 106 | $typeDefinitionMap = []; |
107 | 107 | $typeExtensionsMap = []; |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | |
116 | 116 | if (null !== $existingType) { |
117 | 117 | throw new ExtensionException( |
118 | - \sprintf( |
|
118 | + \sprintf( |
|
119 | 119 | 'Type "%s" already exists in the schema. It cannot also ' . |
120 | 120 | 'be defined in this type definition.', |
121 | 121 | $typeName |
122 | - ), |
|
123 | - [$definition] |
|
122 | + ), |
|
123 | + [$definition] |
|
124 | 124 | ); |
125 | 125 | } |
126 | 126 | |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | |
137 | 137 | if (null === $existingType) { |
138 | 138 | throw new ExtensionException( |
139 | - \sprintf( |
|
139 | + \sprintf( |
|
140 | 140 | 'Cannot extend type "%s" because it does not exist in the existing schema.', |
141 | 141 | $extendedTypeName |
142 | - ), |
|
143 | - [$definition] |
|
142 | + ), |
|
143 | + [$definition] |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $this->checkExtensionNode($existingType, $definition); |
148 | 148 | |
149 | 149 | $typeExtensionsMap[$extendedTypeName] = \array_merge( |
150 | - $typeExtensionsMap[$extendedTypeName] ?? [], |
|
151 | - [$definition] |
|
150 | + $typeExtensionsMap[$extendedTypeName] ?? [], |
|
151 | + [$definition] |
|
152 | 152 | ); |
153 | 153 | |
154 | 154 | continue; |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | |
161 | 161 | if (null !== $existingDirective) { |
162 | 162 | throw new ExtensionException( |
163 | - \sprintf( |
|
163 | + \sprintf( |
|
164 | 164 | 'Directive "%s" already exists in the schema. It cannot be redefined.', |
165 | 165 | $directiveName |
166 | - ), |
|
167 | - [$definition] |
|
166 | + ), |
|
167 | + [$definition] |
|
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
@@ -178,18 +178,18 @@ discard block |
||
178 | 178 | $definition instanceof EnumTypeExtensionNode || |
179 | 179 | $definition instanceof InputObjectTypeExtensionNode) { |
180 | 180 | throw new ExtensionException( |
181 | - \sprintf('The %s kind is not yet supported by extendSchema().', |
|
181 | + \sprintf('The %s kind is not yet supported by extendSchema().', |
|
182 | 182 | $definition->getKind()) |
183 | 183 | ); |
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | 187 | return new ExtendInfo( |
188 | - $schema, |
|
189 | - $document, |
|
190 | - $typeDefinitionMap, |
|
191 | - $typeExtensionsMap, |
|
192 | - $directiveDefinitions |
|
188 | + $schema, |
|
189 | + $document, |
|
190 | + $typeDefinitionMap, |
|
191 | + $typeExtensionsMap, |
|
192 | + $directiveDefinitions |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | * @throws ExtensionException |
201 | 201 | */ |
202 | 202 | protected function checkExtensionNode( |
203 | - TypeInterface $type, |
|
204 | - NodeInterface $node |
|
203 | + TypeInterface $type, |
|
204 | + NodeInterface $node |
|
205 | 205 | ): void { |
206 | 206 | if ($node instanceof ObjectTypeExtensionNode && !($type instanceof ObjectType)) { |
207 | 207 | throw new ExtensionException( |
208 | - \sprintf('Cannot extend non-object type "%s".', toString($type)), |
|
209 | - [$node] |
|
208 | + \sprintf('Cannot extend non-object type "%s".', toString($type)), |
|
209 | + [$node] |
|
210 | 210 | ); |
211 | 211 | } |
212 | 212 | |
213 | 213 | if ($node instanceof InterfaceTypeExtensionNode && !($type instanceof InterfaceType)) { |
214 | 214 | throw new ExtensionException( |
215 | - \sprintf('Cannot extend non-interface type "%s".', |
|
215 | + \sprintf('Cannot extend non-interface type "%s".', |
|
216 | 216 | toString($type)), |
217 | - [$node] |
|
217 | + [$node] |
|
218 | 218 | ); |
219 | 219 | } |
220 | 220 | } |
@@ -47,11 +47,11 @@ |
||
47 | 47 | * @param DirectiveDefinitionNode[] $directiveDefinitions |
48 | 48 | */ |
49 | 49 | public function __construct( |
50 | - SchemaInterface $schema, |
|
51 | - DocumentNode $document, |
|
52 | - array $typeDefinitionMap, |
|
53 | - array $typeExtensionsMap, |
|
54 | - array $directiveDefinitions |
|
50 | + SchemaInterface $schema, |
|
51 | + DocumentNode $document, |
|
52 | + array $typeDefinitionMap, |
|
53 | + array $typeExtensionsMap, |
|
54 | + array $directiveDefinitions |
|
55 | 55 | ) { |
56 | 56 | $this->schema = $schema; |
57 | 57 | $this->document = $document; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @var array |
13 | 13 | */ |
14 | 14 | protected $provides = [ |
15 | - SchemaExtenderInterface::class, |
|
15 | + SchemaExtenderInterface::class, |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | /** |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function register() |
22 | 22 | { |
23 | 23 | $this->container->add(SchemaExtenderInterface::class, |
24 | - SchemaExtender::class) |
|
25 | - ->withArgument(CacheInterface::class); |
|
24 | + SchemaExtender::class) |
|
25 | + ->withArgument(CacheInterface::class); |
|
26 | 26 | } |
27 | 27 | } |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | * @return SchemaInterface |
19 | 19 | */ |
20 | 20 | public function extend( |
21 | - SchemaInterface $schema, |
|
22 | - DocumentNode $document, |
|
21 | + SchemaInterface $schema, |
|
22 | + DocumentNode $document, |
|
23 | 23 | ?ResolverRegistryInterface $resolverRegistry = null, |
24 | - array $options = [] |
|
24 | + array $options = [] |
|
25 | 25 | ): SchemaInterface; |
26 | 26 | |
27 | 27 | /** |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * @return ExtensionContextInterface |
33 | 33 | */ |
34 | 34 | public function createContext( |
35 | - SchemaInterface $schema, |
|
36 | - DocumentNode $document, |
|
35 | + SchemaInterface $schema, |
|
36 | + DocumentNode $document, |
|
37 | 37 | ?ResolverRegistryInterface $resolverRegistry |
38 | 38 | ): ExtensionContextInterface; |
39 | 39 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function isSchemaExtended(): bool |
62 | 62 | { |
63 | 63 | return |
64 | - $this->info->hasTypeExtensionsMap() || |
|
64 | + $this->info->hasTypeExtensionsMap() || |
|
65 | 65 | $this->info->hasTypeDefinitionMap() || |
66 | 66 | $this->info->hasDirectiveDefinitions(); |
67 | 67 | } |
@@ -141,21 +141,21 @@ discard block |
||
141 | 141 | |
142 | 142 | if ($this->info->hasTypeExtensions($typeName)) { |
143 | 143 | $extensionASTNodes = $this->extendExtensionASTNodes($typeName, |
144 | - $extensionASTNodes); |
|
144 | + $extensionASTNodes); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | return newObjectType([ |
148 | - 'name' => $typeName, |
|
149 | - 'description' => $type->getDescription(), |
|
150 | - 'interfaces' => function () use ($type) { |
|
151 | - return $this->extendImplementedInterfaces($type); |
|
152 | - }, |
|
153 | - 'fields' => function () use ($type) { |
|
154 | - return $this->extendFieldMap($type); |
|
155 | - }, |
|
156 | - 'astNode' => $type->getAstNode(), |
|
157 | - 'extensionASTNodes' => $extensionASTNodes, |
|
158 | - 'isTypeOf' => $type->getIsTypeOf(), |
|
148 | + 'name' => $typeName, |
|
149 | + 'description' => $type->getDescription(), |
|
150 | + 'interfaces' => function () use ($type) { |
|
151 | + return $this->extendImplementedInterfaces($type); |
|
152 | + }, |
|
153 | + 'fields' => function () use ($type) { |
|
154 | + return $this->extendFieldMap($type); |
|
155 | + }, |
|
156 | + 'astNode' => $type->getAstNode(), |
|
157 | + 'extensionASTNodes' => $extensionASTNodes, |
|
158 | + 'isTypeOf' => $type->getIsTypeOf(), |
|
159 | 159 | ]); |
160 | 160 | } |
161 | 161 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * @return array |
167 | 167 | */ |
168 | 168 | protected function extendExtensionASTNodes( |
169 | - string $typeName, |
|
170 | - array $nodes |
|
169 | + string $typeName, |
|
170 | + array $nodes |
|
171 | 171 | ): array { |
172 | 172 | $typeExtensions = $this->info->getTypeExtensions($typeName); |
173 | 173 | return !empty($nodes) ? \array_merge($typeExtensions, |
174 | - $nodes) : $typeExtensions; |
|
174 | + $nodes) : $typeExtensions; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | $field = $oldFieldMap[$fieldName]; |
225 | 225 | |
226 | 226 | $newFieldMap[$fieldName] = [ |
227 | - 'description' => $field->getDescription(), |
|
228 | - 'deprecationReason' => $field->getDeprecationReason(), |
|
229 | - 'type' => $this->extendFieldType($field->getType()), |
|
230 | - 'args' => keyMap($field->getArguments(), |
|
227 | + 'description' => $field->getDescription(), |
|
228 | + 'deprecationReason' => $field->getDeprecationReason(), |
|
229 | + 'type' => $this->extendFieldType($field->getType()), |
|
230 | + 'args' => keyMap($field->getArguments(), |
|
231 | 231 | function (Argument $argument) { |
232 | 232 | return $argument->getName(); |
233 | 233 | }), |
234 | - 'astNode' => $field->getAstNode(), |
|
235 | - 'resolve' => $field->getResolve(), |
|
234 | + 'astNode' => $field->getAstNode(), |
|
235 | + 'resolve' => $field->getResolve(), |
|
236 | 236 | ]; |
237 | 237 | } |
238 | 238 | |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | |
247 | 247 | if (isset($oldFieldMap[$fieldName])) { |
248 | 248 | throw new ExtensionException( |
249 | - \sprintf( |
|
249 | + \sprintf( |
|
250 | 250 | 'Field "%s.%s" already exists in the schema. ' . |
251 | 251 | 'It cannot also be defined in this type extension.', |
252 | 252 | $typeName, $fieldName |
253 | - ), |
|
254 | - [$field] |
|
253 | + ), |
|
254 | + [$field] |
|
255 | 255 | ); |
256 | 256 | } |
257 | 257 | |
@@ -296,18 +296,18 @@ discard block |
||
296 | 296 | |
297 | 297 | if ($this->info->hasTypeExtensions($typeName)) { |
298 | 298 | $extensionASTNodes = $this->extendExtensionASTNodes($typeName, |
299 | - $extensionASTNodes); |
|
299 | + $extensionASTNodes); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | return newInterfaceType([ |
303 | - 'name' => $typeName, |
|
304 | - 'description' => $type->getDescription(), |
|
305 | - 'fields' => function () use ($type) { |
|
306 | - return $this->extendFieldMap($type); |
|
307 | - }, |
|
308 | - 'astNode' => $type->getAstNode(), |
|
309 | - 'extensionASTNodes' => $extensionASTNodes, |
|
310 | - 'resolveType' => $type->getResolveType(), |
|
303 | + 'name' => $typeName, |
|
304 | + 'description' => $type->getDescription(), |
|
305 | + 'fields' => function () use ($type) { |
|
306 | + return $this->extendFieldMap($type); |
|
307 | + }, |
|
308 | + 'astNode' => $type->getAstNode(), |
|
309 | + 'extensionASTNodes' => $extensionASTNodes, |
|
310 | + 'resolveType' => $type->getResolveType(), |
|
311 | 311 | ]); |
312 | 312 | } |
313 | 313 | |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | protected function extendUnionType(UnionType $type): UnionType |
321 | 321 | { |
322 | 322 | return newUnionType([ |
323 | - 'name' => $type->getName(), |
|
324 | - 'description' => $type->getDescription(), |
|
325 | - 'types' => \array_map(function ($unionType) { |
|
326 | - return $this->getExtendedType($unionType); |
|
327 | - }, $type->getTypes()), |
|
328 | - 'astNode' => $type->getAstNode(), |
|
329 | - 'resolveType' => $type->getResolveType(), |
|
323 | + 'name' => $type->getName(), |
|
324 | + 'description' => $type->getDescription(), |
|
325 | + 'types' => \array_map(function ($unionType) { |
|
326 | + return $this->getExtendedType($unionType); |
|
327 | + }, $type->getTypes()), |
|
328 | + 'astNode' => $type->getAstNode(), |
|
329 | + 'resolveType' => $type->getResolveType(), |
|
330 | 330 | ]); |
331 | 331 | } |
332 | 332 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function getExtendedSubscriptionType(): ?TypeInterface |
353 | 353 | { |
354 | 354 | $existingSubscriptionType = $this->info->getSchema() |
355 | - ->getSubscriptionType(); |
|
355 | + ->getSubscriptionType(); |
|
356 | 356 | |
357 | 357 | return null !== $existingSubscriptionType |
358 | 358 | ? $this->getExtendedType($existingSubscriptionType) |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | }, $this->info->getSchema()->getTypeMap()); |
370 | 370 | |
371 | 371 | return \array_merge( |
372 | - $extendedTypes, |
|
373 | - $this->definitionBuilder->buildTypes($this->info->getTypeDefinitionMap()) |
|
372 | + $extendedTypes, |
|
373 | + $this->definitionBuilder->buildTypes($this->info->getTypeDefinitionMap()) |
|
374 | 374 | ); |
375 | 375 | } |
376 | 376 | |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | $existingDirectives = $this->info->getSchema()->getDirectives(); |
384 | 384 | |
385 | 385 | invariant(!empty($existingDirectives), |
386 | - 'schema must have default directives'); |
|
386 | + 'schema must have default directives'); |
|
387 | 387 | |
388 | 388 | return \array_merge( |
389 | - $existingDirectives, |
|
390 | - \array_map(function (DirectiveDefinitionNode $node) { |
|
391 | - return $this->definitionBuilder->buildDirective($node); |
|
392 | - }, $this->info->getDirectiveDefinitions()) |
|
389 | + $existingDirectives, |
|
390 | + \array_map(function (DirectiveDefinitionNode $node) { |
|
391 | + return $this->definitionBuilder->buildDirective($node); |
|
392 | + }, $this->info->getDirectiveDefinitions()) |
|
393 | 393 | ); |
394 | 394 | } |
395 | 395 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @return ExtensionContext |
400 | 400 | */ |
401 | 401 | public function setDefinitionBuilder( |
402 | - DefinitionBuilderInterface $definitionBuilder |
|
402 | + DefinitionBuilderInterface $definitionBuilder |
|
403 | 403 | ): ExtensionContext { |
404 | 404 | $this->definitionBuilder = $definitionBuilder; |
405 | 405 | return $this; |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | throw new ExtensionException( |
426 | - \sprintf( |
|
426 | + \sprintf( |
|
427 | 427 | 'Unknown type: "%s". Ensure that this type exists ' . |
428 | 428 | 'either in the original schema, or is added in a type definition.', |
429 | 429 | $typeName |
430 | - ), |
|
431 | - [$node] |
|
430 | + ), |
|
431 | + [$node] |
|
432 | 432 | ); |
433 | 433 | } |
434 | 434 | } |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | return newObjectType([ |
148 | 148 | 'name' => $typeName, |
149 | 149 | 'description' => $type->getDescription(), |
150 | - 'interfaces' => function () use ($type) { |
|
150 | + 'interfaces' => function() use ($type) { |
|
151 | 151 | return $this->extendImplementedInterfaces($type); |
152 | 152 | }, |
153 | - 'fields' => function () use ($type) { |
|
153 | + 'fields' => function() use ($type) { |
|
154 | 154 | return $this->extendFieldMap($type); |
155 | 155 | }, |
156 | 156 | 'astNode' => $type->getAstNode(), |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | { |
185 | 185 | $typeName = $type->getName(); |
186 | 186 | |
187 | - $interfaces = \array_map(function (InterfaceType $interface) { |
|
187 | + $interfaces = \array_map(function(InterfaceType $interface) { |
|
188 | 188 | return $this->getExtendedType($interface); |
189 | 189 | }, $type->getInterfaces()); |
190 | 190 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | 'deprecationReason' => $field->getDeprecationReason(), |
229 | 229 | 'type' => $this->extendFieldType($field->getType()), |
230 | 230 | 'args' => keyMap($field->getArguments(), |
231 | - function (Argument $argument) { |
|
231 | + function(Argument $argument) { |
|
232 | 232 | return $argument->getName(); |
233 | 233 | }), |
234 | 234 | 'astNode' => $field->getAstNode(), |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | return newInterfaceType([ |
303 | 303 | 'name' => $typeName, |
304 | 304 | 'description' => $type->getDescription(), |
305 | - 'fields' => function () use ($type) { |
|
305 | + 'fields' => function() use ($type) { |
|
306 | 306 | return $this->extendFieldMap($type); |
307 | 307 | }, |
308 | 308 | 'astNode' => $type->getAstNode(), |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | return newUnionType([ |
323 | 323 | 'name' => $type->getName(), |
324 | 324 | 'description' => $type->getDescription(), |
325 | - 'types' => \array_map(function ($unionType) { |
|
325 | + 'types' => \array_map(function($unionType) { |
|
326 | 326 | return $this->getExtendedType($unionType); |
327 | 327 | }, $type->getTypes()), |
328 | 328 | 'astNode' => $type->getAstNode(), |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function getExtendedTypes(): array |
366 | 366 | { |
367 | - $extendedTypes = \array_map(function ($type) { |
|
367 | + $extendedTypes = \array_map(function($type) { |
|
368 | 368 | return $this->getExtendedType($type); |
369 | 369 | }, $this->info->getSchema()->getTypeMap()); |
370 | 370 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | return \array_merge( |
389 | 389 | $existingDirectives, |
390 | - \array_map(function (DirectiveDefinitionNode $node) { |
|
390 | + \array_map(function(DirectiveDefinitionNode $node) { |
|
391 | 391 | return $this->definitionBuilder->buildDirective($node); |
392 | 392 | }, $this->info->getDirectiveDefinitions()) |
393 | 393 | ); |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | |
22 | 22 | if (!empty($errors)) { |
23 | 23 | $message = \implode("\n", |
24 | - \array_map(function (SchemaValidationException $error) { |
|
25 | - return $error->getMessage(); |
|
26 | - }, $errors)); |
|
24 | + \array_map(function (SchemaValidationException $error) { |
|
25 | + return $error->getMessage(); |
|
26 | + }, $errors)); |
|
27 | 27 | |
28 | 28 | throw new SchemaValidationException($message); |
29 | 29 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @return SchemaValidationException[] |
37 | 37 | */ |
38 | 38 | public function validate( |
39 | - SchemaInterface $schema, |
|
39 | + SchemaInterface $schema, |
|
40 | 40 | ?array $rules = null |
41 | 41 | ): array { |
42 | 42 | $context = $this->createContext($schema); |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | if (!empty($errors)) { |
23 | 23 | $message = \implode("\n", |
24 | - \array_map(function (SchemaValidationException $error) { |
|
24 | + \array_map(function(SchemaValidationException $error) { |
|
25 | 25 | return $error->getMessage(); |
26 | 26 | }, $errors)); |
27 | 27 |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | * @var array |
15 | 15 | */ |
16 | 16 | protected $provides = [ |
17 | - SchemaValidatorInterface::class, |
|
18 | - RootTypesRule::class, |
|
19 | - DirectivesRule::class, |
|
20 | - TypesRule::class, |
|
17 | + SchemaValidatorInterface::class, |
|
18 | + RootTypesRule::class, |
|
19 | + DirectivesRule::class, |
|
20 | + TypesRule::class, |
|
21 | 21 | ]; |
22 | 22 | |
23 | 23 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function register() |
27 | 27 | { |
28 | 28 | $this->container->add(SchemaValidatorInterface::class, |
29 | - SchemaValidator::class, true); |
|
29 | + SchemaValidator::class, true); |
|
30 | 30 | |
31 | 31 | // Rules |
32 | 32 | $this->container->add(RootTypesRule::class, RootTypesRule::class); |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | foreach ($typeMap as $type) { |
47 | 47 | if (!($type instanceof NamedTypeInterface)) { |
48 | 48 | $this->context->reportError( |
49 | - new SchemaValidationException( |
|
49 | + new SchemaValidationException( |
|
50 | 50 | \sprintf('Expected GraphQL named type but got: %s.', |
51 | - toString($type)), |
|
51 | + toString($type)), |
|
52 | 52 | $type instanceof NodeAwareInterface ? [$type->getAstNode()] : null |
53 | - ) |
|
53 | + ) |
|
54 | 54 | ); |
55 | 55 | |
56 | 56 | continue; |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | // Objects and Interfaces both must define one or more fields. |
124 | 124 | if (empty($fields)) { |
125 | 125 | $this->context->reportError( |
126 | - new SchemaValidationException( |
|
126 | + new SchemaValidationException( |
|
127 | 127 | \sprintf('Type %s must define one or more fields.', |
128 | - $type->getName()), |
|
128 | + $type->getName()), |
|
129 | 129 | $this->getAllObjectOrInterfaceNodes($type) |
130 | - ) |
|
130 | + ) |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | |
141 | 141 | if (\count($fieldNodes) > 1) { |
142 | 142 | $this->context->reportError( |
143 | - new SchemaValidationException( |
|
143 | + new SchemaValidationException( |
|
144 | 144 | \sprintf('Field %s.%s can only be defined once.', |
145 | - $type->getName(), $fieldName), |
|
145 | + $type->getName(), $fieldName), |
|
146 | 146 | $fieldNodes |
147 | - ) |
|
147 | + ) |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | return; // continue loop |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | if (!isOutputType($fieldType)) { |
157 | 157 | $fieldTypeNode = $this->getFieldTypeNode($type, $fieldName); |
158 | 158 | $this->context->reportError( |
159 | - new SchemaValidationException( |
|
159 | + new SchemaValidationException( |
|
160 | 160 | \sprintf( |
161 | - 'The type of %s.%s must be Output Type but got: %s.', |
|
162 | - $type->getName(), |
|
163 | - $fieldName, |
|
164 | - toString($fieldType) |
|
161 | + 'The type of %s.%s must be Output Type but got: %s.', |
|
162 | + $type->getName(), |
|
163 | + $fieldName, |
|
164 | + toString($fieldType) |
|
165 | 165 | ), |
166 | 166 | [$fieldTypeNode] |
167 | - ) |
|
167 | + ) |
|
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
@@ -180,16 +180,16 @@ discard block |
||
180 | 180 | // Ensure they are unique per field. |
181 | 181 | if (isset($argumentNames[$argumentName])) { |
182 | 182 | $this->context->reportError( |
183 | - new SchemaValidationException( |
|
183 | + new SchemaValidationException( |
|
184 | 184 | \sprintf( |
185 | - 'Field argument %s.%s(%s:) can only be defined once.', |
|
186 | - $type->getName(), |
|
187 | - $field->getName(), |
|
188 | - $argumentName |
|
185 | + 'Field argument %s.%s(%s:) can only be defined once.', |
|
186 | + $type->getName(), |
|
187 | + $field->getName(), |
|
188 | + $argumentName |
|
189 | 189 | ), |
190 | 190 | $this->getAllFieldArgumentNodes($type, $fieldName, |
191 | - $argumentName) |
|
192 | - ) |
|
191 | + $argumentName) |
|
192 | + ) |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | // Ensure the type is an input type |
199 | 199 | if (!isInputType($argument->getType())) { |
200 | 200 | $this->context->reportError( |
201 | - new SchemaValidationException( |
|
201 | + new SchemaValidationException( |
|
202 | 202 | \sprintf( |
203 | - 'The type of %s.%s(%s:) must be Input Type but got: %s.', |
|
204 | - $type->getName(), |
|
205 | - $fieldName, |
|
206 | - $argumentName, |
|
207 | - toString($argument->getType()) |
|
203 | + 'The type of %s.%s(%s:) must be Input Type but got: %s.', |
|
204 | + $type->getName(), |
|
205 | + $fieldName, |
|
206 | + $argumentName, |
|
207 | + toString($argument->getType()) |
|
208 | 208 | ), |
209 | 209 | $this->getAllFieldArgumentNodes($type, $fieldName, |
210 | - $argumentName) |
|
211 | - ) |
|
210 | + $argumentName) |
|
211 | + ) |
|
212 | 212 | ); |
213 | 213 | } |
214 | 214 | } |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * @return FieldDefinitionNode[] |
243 | 243 | */ |
244 | 244 | protected function getAllFieldNodes( |
245 | - NamedTypeInterface $type, |
|
246 | - string $fieldName |
|
245 | + NamedTypeInterface $type, |
|
246 | + string $fieldName |
|
247 | 247 | ): array { |
248 | 248 | $nodes = []; |
249 | 249 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * @return TypeNodeInterface|null |
266 | 266 | */ |
267 | 267 | protected function getFieldTypeNode( |
268 | - NamedTypeInterface $type, |
|
269 | - string $fieldName |
|
268 | + NamedTypeInterface $type, |
|
269 | + string $fieldName |
|
270 | 270 | ): ?TypeNodeInterface |
271 | 271 | { |
272 | 272 | $fieldNode = $this->getFieldNode($type, $fieldName); |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | * @return FieldDefinitionNode|null |
281 | 281 | */ |
282 | 282 | protected function getFieldNode( |
283 | - NamedTypeInterface $type, |
|
284 | - string $fieldName |
|
283 | + NamedTypeInterface $type, |
|
284 | + string $fieldName |
|
285 | 285 | ): ?FieldDefinitionNode |
286 | 286 | { |
287 | 287 | return $this->getAllFieldNodes($type, $fieldName)[0] ?? null; |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | * @return InputValueDefinitionNode[] |
296 | 296 | */ |
297 | 297 | protected function getAllFieldArgumentNodes( |
298 | - NamedTypeInterface $type, |
|
299 | - string $fieldName, |
|
300 | - string $argumentName |
|
298 | + NamedTypeInterface $type, |
|
299 | + string $fieldName, |
|
300 | + string $argumentName |
|
301 | 301 | ): array { |
302 | 302 | $nodes = []; |
303 | 303 | |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | foreach ($objectType->getInterfaces() as $interface) { |
327 | 327 | if (!($interface instanceof InterfaceType)) { |
328 | 328 | $this->context->reportError( |
329 | - new SchemaValidationException( |
|
329 | + new SchemaValidationException( |
|
330 | 330 | \sprintf( |
331 | - 'Type %s must only implement Interface types, it cannot implement %s.', |
|
332 | - toString($objectType), |
|
333 | - toString($interface) |
|
331 | + 'Type %s must only implement Interface types, it cannot implement %s.', |
|
332 | + toString($objectType), |
|
333 | + toString($interface) |
|
334 | 334 | ), |
335 | 335 | null !== $interface |
336 | 336 | ? [ |
337 | - $this->getImplementsInterfaceNode($objectType, |
|
337 | + $this->getImplementsInterfaceNode($objectType, |
|
338 | 338 | $interface->getName()), |
339 | 339 | ] |
340 | 340 | : null |
341 | - ) |
|
341 | + ) |
|
342 | 342 | ); |
343 | 343 | |
344 | 344 | continue; |
@@ -348,12 +348,12 @@ discard block |
||
348 | 348 | |
349 | 349 | if (isset($implementedTypeNames[$interfaceName])) { |
350 | 350 | $this->context->reportError( |
351 | - new SchemaValidationException( |
|
351 | + new SchemaValidationException( |
|
352 | 352 | \sprintf('Type %s can only implement %s once.', |
353 | - $objectType->getName(), $interfaceName), |
|
353 | + $objectType->getName(), $interfaceName), |
|
354 | 354 | $this->getAllImplementsInterfaceNodes($objectType, |
355 | - $interfaceName) |
|
356 | - ) |
|
355 | + $interfaceName) |
|
356 | + ) |
|
357 | 357 | ); |
358 | 358 | |
359 | 359 | continue; |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * @return NamedTypeNode|null |
373 | 373 | */ |
374 | 374 | protected function getImplementsInterfaceNode( |
375 | - ObjectType $type, |
|
376 | - string $interfaceName |
|
375 | + ObjectType $type, |
|
376 | + string $interfaceName |
|
377 | 377 | ): ?NamedTypeNode |
378 | 378 | { |
379 | 379 | return $this->getAllImplementsInterfaceNodes($type, |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | * @return NamedTypeNode[] |
388 | 388 | */ |
389 | 389 | protected function getAllImplementsInterfaceNodes( |
390 | - ObjectType $type, |
|
391 | - string $interfaceName |
|
390 | + ObjectType $type, |
|
391 | + string $interfaceName |
|
392 | 392 | ): array { |
393 | 393 | $nodes = []; |
394 | 394 | |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | * @throws InvariantException |
411 | 411 | */ |
412 | 412 | protected function validateObjectImplementsInterface( |
413 | - ObjectType $objectType, |
|
414 | - InterfaceType $interfaceType |
|
413 | + ObjectType $objectType, |
|
414 | + InterfaceType $interfaceType |
|
415 | 415 | ): void { |
416 | 416 | $objectFields = $objectType->getFields(); |
417 | 417 | $interfaceFields = $interfaceType->getFields(); |
@@ -424,18 +424,18 @@ discard block |
||
424 | 424 | // Assert interface field exists on object. |
425 | 425 | if (null === $objectField) { |
426 | 426 | $this->context->reportError( |
427 | - new SchemaValidationException( |
|
427 | + new SchemaValidationException( |
|
428 | 428 | \sprintf( |
429 | - 'Interface field %s.%s expected but %s does not provide it.', |
|
430 | - $interfaceType->getName(), |
|
431 | - $fieldName, |
|
432 | - $objectType->getName() |
|
429 | + 'Interface field %s.%s expected but %s does not provide it.', |
|
430 | + $interfaceType->getName(), |
|
431 | + $fieldName, |
|
432 | + $objectType->getName() |
|
433 | 433 | ), |
434 | 434 | [ |
435 | - $this->getFieldNode($interfaceType, $fieldName), |
|
436 | - $objectType->getAstNode(), |
|
435 | + $this->getFieldNode($interfaceType, $fieldName), |
|
436 | + $objectType->getAstNode(), |
|
437 | 437 | ] |
438 | - ) |
|
438 | + ) |
|
439 | 439 | ); |
440 | 440 | |
441 | 441 | continue; |
@@ -444,24 +444,24 @@ discard block |
||
444 | 444 | // Assert interface field type is satisfied by object field type, by being |
445 | 445 | // a valid subtype. (covariant) |
446 | 446 | if (!isTypeSubtypeOf( |
447 | - $this->context->getSchema(), $objectField->getType(), |
|
448 | - $interfaceField->getType())) { |
|
447 | + $this->context->getSchema(), $objectField->getType(), |
|
448 | + $interfaceField->getType())) { |
|
449 | 449 | $this->context->reportError( |
450 | - new SchemaValidationException( |
|
450 | + new SchemaValidationException( |
|
451 | 451 | \sprintf( |
452 | - 'Interface field %s.%s expects type %s but %s.%s is type %s.', |
|
453 | - $interfaceType->getName(), |
|
454 | - $fieldName, |
|
455 | - toString($interfaceField->getType()), |
|
456 | - $objectType->getName(), |
|
457 | - $fieldName, |
|
458 | - toString($objectField->getType()) |
|
452 | + 'Interface field %s.%s expects type %s but %s.%s is type %s.', |
|
453 | + $interfaceType->getName(), |
|
454 | + $fieldName, |
|
455 | + toString($interfaceField->getType()), |
|
456 | + $objectType->getName(), |
|
457 | + $fieldName, |
|
458 | + toString($objectField->getType()) |
|
459 | 459 | ), |
460 | 460 | [ |
461 | - $this->getFieldTypeNode($interfaceType, $fieldName), |
|
462 | - $this->getFieldTypeNode($objectType, $fieldName), |
|
461 | + $this->getFieldTypeNode($interfaceType, $fieldName), |
|
462 | + $this->getFieldTypeNode($objectType, $fieldName), |
|
463 | 463 | ] |
464 | - ) |
|
464 | + ) |
|
465 | 465 | ); |
466 | 466 | } |
467 | 467 | |
@@ -469,28 +469,28 @@ discard block |
||
469 | 469 | foreach ($interfaceField->getArguments() as $interfaceArgument) { |
470 | 470 | $argumentName = $interfaceArgument->getName(); |
471 | 471 | $objectArgument = find($objectField->getArguments(), |
472 | - function (Argument $argument) use ($argumentName) { |
|
473 | - return $argument->getName() === $argumentName; |
|
474 | - }); |
|
472 | + function (Argument $argument) use ($argumentName) { |
|
473 | + return $argument->getName() === $argumentName; |
|
474 | + }); |
|
475 | 475 | |
476 | 476 | // Assert interface field arg exists on object field. |
477 | 477 | if (null === $objectArgument) { |
478 | 478 | $this->context->reportError( |
479 | - new SchemaValidationException( |
|
479 | + new SchemaValidationException( |
|
480 | 480 | \sprintf( |
481 | - 'Interface field argument %s.%s(%s:) expected but %s.%s does not provide it.', |
|
482 | - $interfaceType->getName(), |
|
483 | - $fieldName, |
|
484 | - $argumentName, |
|
485 | - $objectType->getName(), |
|
486 | - $fieldName |
|
481 | + 'Interface field argument %s.%s(%s:) expected but %s.%s does not provide it.', |
|
482 | + $interfaceType->getName(), |
|
483 | + $fieldName, |
|
484 | + $argumentName, |
|
485 | + $objectType->getName(), |
|
486 | + $fieldName |
|
487 | 487 | ), |
488 | 488 | [ |
489 | - $this->getFieldArgumentNode($interfaceType, |
|
489 | + $this->getFieldArgumentNode($interfaceType, |
|
490 | 490 | $fieldName, $argumentName), |
491 | - $this->getFieldNode($objectType, $fieldName), |
|
491 | + $this->getFieldNode($objectType, $fieldName), |
|
492 | 492 | ] |
493 | - ) |
|
493 | + ) |
|
494 | 494 | ); |
495 | 495 | |
496 | 496 | continue; |
@@ -500,27 +500,27 @@ discard block |
||
500 | 500 | // (invariant) |
501 | 501 | // TODO: change to contravariant? |
502 | 502 | if (!isEqualType($interfaceArgument->getType(), |
503 | - $objectArgument->getType())) { |
|
503 | + $objectArgument->getType())) { |
|
504 | 504 | $this->context->reportError( |
505 | - new SchemaValidationException( |
|
505 | + new SchemaValidationException( |
|
506 | 506 | \sprintf( |
507 | - 'Interface field argument %s.%s(%s:) expects type %s but %s.%s(%s:) is type %s.', |
|
508 | - $interfaceType->getName(), |
|
509 | - $fieldName, |
|
510 | - $argumentName, |
|
511 | - toString($interfaceArgument->getType()), |
|
512 | - $objectType->getName(), |
|
513 | - $fieldName, |
|
514 | - $argumentName, |
|
515 | - toString($objectArgument->getType()) |
|
507 | + 'Interface field argument %s.%s(%s:) expects type %s but %s.%s(%s:) is type %s.', |
|
508 | + $interfaceType->getName(), |
|
509 | + $fieldName, |
|
510 | + $argumentName, |
|
511 | + toString($interfaceArgument->getType()), |
|
512 | + $objectType->getName(), |
|
513 | + $fieldName, |
|
514 | + $argumentName, |
|
515 | + toString($objectArgument->getType()) |
|
516 | 516 | ), |
517 | 517 | [ |
518 | - $this->getFieldArgumentTypeNode($interfaceType, |
|
518 | + $this->getFieldArgumentTypeNode($interfaceType, |
|
519 | 519 | $fieldName, $argumentName), |
520 | - $this->getFieldArgumentTypeNode($objectType, |
|
520 | + $this->getFieldArgumentTypeNode($objectType, |
|
521 | 521 | $fieldName, $argumentName), |
522 | 522 | ] |
523 | - ) |
|
523 | + ) |
|
524 | 524 | ); |
525 | 525 | |
526 | 526 | continue; |
@@ -531,31 +531,31 @@ discard block |
||
531 | 531 | foreach ($objectField->getArguments() as $objectArgument) { |
532 | 532 | $argumentName = $objectArgument->getName(); |
533 | 533 | $interfaceArgument = find( |
534 | - $interfaceField->getArguments(), |
|
535 | - function (Argument $argument) use ($argumentName) { |
|
536 | - return $argument->getName() === $argumentName; |
|
537 | - } |
|
534 | + $interfaceField->getArguments(), |
|
535 | + function (Argument $argument) use ($argumentName) { |
|
536 | + return $argument->getName() === $argumentName; |
|
537 | + } |
|
538 | 538 | ); |
539 | 539 | |
540 | 540 | if (null === $interfaceArgument && $objectArgument->getType() instanceof NonNullType) { |
541 | 541 | $this->context->reportError( |
542 | - new SchemaValidationException( |
|
542 | + new SchemaValidationException( |
|
543 | 543 | \sprintf( |
544 | - 'Object field argument %s.%s(%s:) is of required type %s ' . |
|
545 | - 'but is not also provided by the Interface field %s.%s.', |
|
546 | - $objectType->getName(), |
|
547 | - $fieldName, |
|
548 | - $argumentName, |
|
549 | - toString($objectArgument->getType()), |
|
550 | - $interfaceType->getName(), |
|
551 | - $fieldName |
|
544 | + 'Object field argument %s.%s(%s:) is of required type %s ' . |
|
545 | + 'but is not also provided by the Interface field %s.%s.', |
|
546 | + $objectType->getName(), |
|
547 | + $fieldName, |
|
548 | + $argumentName, |
|
549 | + toString($objectArgument->getType()), |
|
550 | + $interfaceType->getName(), |
|
551 | + $fieldName |
|
552 | 552 | ), |
553 | 553 | [ |
554 | - $this->getFieldArgumentNode($objectType, |
|
554 | + $this->getFieldArgumentNode($objectType, |
|
555 | 555 | $fieldName, $argumentName), |
556 | - $this->getFieldNode($interfaceType, $fieldName), |
|
556 | + $this->getFieldNode($interfaceType, $fieldName), |
|
557 | 557 | ] |
558 | - ) |
|
558 | + ) |
|
559 | 559 | ); |
560 | 560 | |
561 | 561 | continue; |
@@ -573,9 +573,9 @@ discard block |
||
573 | 573 | * @return InputValueDefinitionNode|null |
574 | 574 | */ |
575 | 575 | protected function getFieldArgumentNode( |
576 | - NamedTypeInterface $type, |
|
577 | - string $fieldName, |
|
578 | - string $argumentName |
|
576 | + NamedTypeInterface $type, |
|
577 | + string $fieldName, |
|
578 | + string $argumentName |
|
579 | 579 | ): ?InputValueDefinitionNode |
580 | 580 | { |
581 | 581 | return $this->getAllFieldArgumentNodes($type, $fieldName, |
@@ -590,9 +590,9 @@ discard block |
||
590 | 590 | * @return TypeNodeInterface|null |
591 | 591 | */ |
592 | 592 | protected function getFieldArgumentTypeNode( |
593 | - NamedTypeInterface $type, |
|
594 | - string $fieldName, |
|
595 | - string $argumentName |
|
593 | + NamedTypeInterface $type, |
|
594 | + string $fieldName, |
|
595 | + string $argumentName |
|
596 | 596 | ): ?TypeNodeInterface |
597 | 597 | { |
598 | 598 | $node = $this->getFieldArgumentNode($type, $fieldName, $argumentName); |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | |
612 | 612 | if (empty($memberTypes)) { |
613 | 613 | $this->context->reportError( |
614 | - new SchemaValidationException( |
|
614 | + new SchemaValidationException( |
|
615 | 615 | sprintf('Union type %s must define one or more member types.', |
616 | - $unionType->getName()), |
|
616 | + $unionType->getName()), |
|
617 | 617 | [$unionType->getAstNode()] |
618 | - ) |
|
618 | + ) |
|
619 | 619 | ); |
620 | 620 | } |
621 | 621 | |
@@ -625,14 +625,14 @@ discard block |
||
625 | 625 | $memberTypeName = $memberType->getName(); |
626 | 626 | if (isset($includedTypeNames[$memberTypeName])) { |
627 | 627 | $this->context->reportError( |
628 | - new SchemaValidationException( |
|
628 | + new SchemaValidationException( |
|
629 | 629 | \sprintf( |
630 | - 'Union type %s can only include type %s once.', |
|
631 | - $unionType->getName(), |
|
632 | - $memberTypeName |
|
630 | + 'Union type %s can only include type %s once.', |
|
631 | + $unionType->getName(), |
|
632 | + $memberTypeName |
|
633 | 633 | ), |
634 | 634 | $this->getUnionMemberTypeNodes($unionType, $memberTypeName) |
635 | - ) |
|
635 | + ) |
|
636 | 636 | ); |
637 | 637 | |
638 | 638 | continue; |
@@ -642,17 +642,17 @@ discard block |
||
642 | 642 | |
643 | 643 | if (!($memberType instanceof ObjectType)) { |
644 | 644 | $this->context->reportError( |
645 | - new SchemaValidationException( |
|
645 | + new SchemaValidationException( |
|
646 | 646 | \sprintf( |
647 | - 'Union type %s can only include Object types, it cannot include %s.', |
|
648 | - $unionType->getName(), |
|
649 | - toString($memberType) |
|
647 | + 'Union type %s can only include Object types, it cannot include %s.', |
|
648 | + $unionType->getName(), |
|
649 | + toString($memberType) |
|
650 | 650 | ), |
651 | 651 | null !== $memberTypeName |
652 | 652 | ? $this->getUnionMemberTypeNodes($unionType, |
653 | - $memberTypeName) |
|
653 | + $memberTypeName) |
|
654 | 654 | : null |
655 | - ) |
|
655 | + ) |
|
656 | 656 | ); |
657 | 657 | } |
658 | 658 | } |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | * @return array|null |
666 | 666 | */ |
667 | 667 | protected function getUnionMemberTypeNodes( |
668 | - UnionType $unionType, |
|
669 | - string $memberTypeName |
|
668 | + UnionType $unionType, |
|
669 | + string $memberTypeName |
|
670 | 670 | ): ?array |
671 | 671 | { |
672 | 672 | /** @var UnionTypeDefinitionNode $node */ |
@@ -677,9 +677,9 @@ discard block |
||
677 | 677 | } |
678 | 678 | |
679 | 679 | return \array_filter($node->getTypes(), |
680 | - function (NamedTypeNode $type) use ($memberTypeName) { |
|
681 | - return $type->getNameValue() === $memberTypeName; |
|
682 | - }); |
|
680 | + function (NamedTypeNode $type) use ($memberTypeName) { |
|
681 | + return $type->getNameValue() === $memberTypeName; |
|
682 | + }); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | /** |
@@ -694,11 +694,11 @@ discard block |
||
694 | 694 | |
695 | 695 | if (empty($enumValues)) { |
696 | 696 | $this->context->reportError( |
697 | - new SchemaValidationException( |
|
697 | + new SchemaValidationException( |
|
698 | 698 | \sprintf('Enum type %s must define one or more values.', |
699 | - $enumType->getName()), |
|
699 | + $enumType->getName()), |
|
700 | 700 | [$enumType->getAstNode()] |
701 | - ) |
|
701 | + ) |
|
702 | 702 | ); |
703 | 703 | } |
704 | 704 | |
@@ -710,11 +710,11 @@ discard block |
||
710 | 710 | |
711 | 711 | if (null !== $allNodes && \count($allNodes) > 1) { |
712 | 712 | $this->context->reportError( |
713 | - new SchemaValidationException( |
|
713 | + new SchemaValidationException( |
|
714 | 714 | sprintf('Enum type %s can include value %s only once.', |
715 | - $enumType->getName(), $valueName), |
|
715 | + $enumType->getName(), $valueName), |
|
716 | 716 | $allNodes |
717 | - ) |
|
717 | + ) |
|
718 | 718 | ); |
719 | 719 | |
720 | 720 | continue; |
@@ -725,11 +725,11 @@ discard block |
||
725 | 725 | |
726 | 726 | if ($valueName === 'true' || $valueName === 'false' || $valueName === 'null') { |
727 | 727 | $this->context->reportError( |
728 | - new SchemaValidationException( |
|
728 | + new SchemaValidationException( |
|
729 | 729 | sprintf('Enum type %s cannot include value: %s.', |
730 | - $enumType->getName(), $valueName), |
|
730 | + $enumType->getName(), $valueName), |
|
731 | 731 | [$enumValue->getAstNode()] |
732 | - ) |
|
732 | + ) |
|
733 | 733 | ); |
734 | 734 | |
735 | 735 | continue; |
@@ -744,8 +744,8 @@ discard block |
||
744 | 744 | * @return array|null |
745 | 745 | */ |
746 | 746 | protected function getEnumValueNodes( |
747 | - EnumType $enumType, |
|
748 | - string $valueName |
|
747 | + EnumType $enumType, |
|
748 | + string $valueName |
|
749 | 749 | ): ?array |
750 | 750 | { |
751 | 751 | /** @var EnumTypeDefinitionNode $node */ |
@@ -756,9 +756,9 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | return \array_filter($node->getValues(), |
759 | - function (NameAwareInterface $type) use ($valueName) { |
|
760 | - return $type->getNameValue() === $valueName; |
|
761 | - }); |
|
759 | + function (NameAwareInterface $type) use ($valueName) { |
|
760 | + return $type->getNameValue() === $valueName; |
|
761 | + }); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | /** |
@@ -773,11 +773,11 @@ discard block |
||
773 | 773 | |
774 | 774 | if (empty($fields)) { |
775 | 775 | $this->context->reportError( |
776 | - new SchemaValidationException( |
|
776 | + new SchemaValidationException( |
|
777 | 777 | \sprintf('Input Object type %s must define one or more fields.', |
778 | - $inputObjectType->getName()), |
|
778 | + $inputObjectType->getName()), |
|
779 | 779 | [$inputObjectType->getAstNode()] |
780 | - ) |
|
780 | + ) |
|
781 | 781 | ); |
782 | 782 | } |
783 | 783 | |
@@ -791,15 +791,15 @@ discard block |
||
791 | 791 | // Ensure the type is an input type |
792 | 792 | if (!isInputType($field->getType())) { |
793 | 793 | $this->context->reportError( |
794 | - new SchemaValidationException( |
|
794 | + new SchemaValidationException( |
|
795 | 795 | \sprintf( |
796 | - 'The type of %s.%s must be Input Type but got: %s.', |
|
797 | - $inputObjectType->getName(), |
|
798 | - $fieldName, |
|
799 | - toString($field->getType()) |
|
796 | + 'The type of %s.%s must be Input Type but got: %s.', |
|
797 | + $inputObjectType->getName(), |
|
798 | + $fieldName, |
|
799 | + toString($field->getType()) |
|
800 | 800 | ), |
801 | 801 | [$field->getAstNode()] |
802 | - ) |
|
802 | + ) |
|
803 | 803 | ); |
804 | 804 | } |
805 | 805 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | foreach ($interfaceField->getArguments() as $interfaceArgument) { |
470 | 470 | $argumentName = $interfaceArgument->getName(); |
471 | 471 | $objectArgument = find($objectField->getArguments(), |
472 | - function (Argument $argument) use ($argumentName) { |
|
472 | + function(Argument $argument) use ($argumentName) { |
|
473 | 473 | return $argument->getName() === $argumentName; |
474 | 474 | }); |
475 | 475 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | $argumentName = $objectArgument->getName(); |
533 | 533 | $interfaceArgument = find( |
534 | 534 | $interfaceField->getArguments(), |
535 | - function (Argument $argument) use ($argumentName) { |
|
535 | + function(Argument $argument) use ($argumentName) { |
|
536 | 536 | return $argument->getName() === $argumentName; |
537 | 537 | } |
538 | 538 | ); |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | } |
678 | 678 | |
679 | 679 | return \array_filter($node->getTypes(), |
680 | - function (NamedTypeNode $type) use ($memberTypeName) { |
|
680 | + function(NamedTypeNode $type) use ($memberTypeName) { |
|
681 | 681 | return $type->getNameValue() === $memberTypeName; |
682 | 682 | }); |
683 | 683 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | return \array_filter($node->getValues(), |
759 | - function (NameAwareInterface $type) use ($valueName) { |
|
759 | + function(NameAwareInterface $type) use ($valueName) { |
|
760 | 760 | return $type->getNameValue() === $valueName; |
761 | 761 | }); |
762 | 762 | } |