@@ -46,7 +46,7 @@ |
||
46 | 46 | if (is_object($value) && method_exists($value, '__toString')) { |
47 | 47 | return (string) $value; |
48 | 48 | } |
49 | - if (! is_scalar($value)) { |
|
49 | + if (!is_scalar($value)) { |
|
50 | 50 | throw new Error('String cannot represent non scalar value: ' . Utils::printSafe($value)); |
51 | 51 | } |
52 | 52 |
@@ -82,7 +82,7 @@ |
||
82 | 82 | */ |
83 | 83 | public static function getInternalDirectives() |
84 | 84 | { |
85 | - if (! self::$internalDirectives) { |
|
85 | + if (!self::$internalDirectives) { |
|
86 | 86 | self::$internalDirectives = [ |
87 | 87 | 'include' => new self([ |
88 | 88 | 'name' => 'include', |
@@ -43,7 +43,7 @@ |
||
43 | 43 | ); |
44 | 44 | } |
45 | 45 | |
46 | - if (! is_numeric($value) && $value !== true && $value !== false) { |
|
46 | + if (!is_numeric($value) && $value !== true && $value !== false) { |
|
47 | 47 | throw new Error( |
48 | 48 | 'Float cannot represent non numeric value: ' . |
49 | 49 | Utils::printSafe($value) |
@@ -63,7 +63,7 @@ |
||
63 | 63 | { |
64 | 64 | $config = new static(); |
65 | 65 | |
66 | - if (! empty($options)) { |
|
66 | + if (!empty($options)) { |
|
67 | 67 | if (isset($options['query'])) { |
68 | 68 | $config->setQuery($options['query']); |
69 | 69 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | public function validateRootTypes() |
65 | 65 | { |
66 | 66 | $queryType = $this->schema->getQueryType(); |
67 | - if (! $queryType) { |
|
67 | + if (!$queryType) { |
|
68 | 68 | $this->reportError( |
69 | 69 | 'Query root type must be provided.', |
70 | 70 | $this->schema->getAstNode() |
71 | 71 | ); |
72 | - } elseif (! $queryType instanceof ObjectType) { |
|
72 | + } elseif (!$queryType instanceof ObjectType) { |
|
73 | 73 | $this->reportError( |
74 | 74 | 'Query root type must be Object type, it cannot be ' . Utils::printSafe($queryType) . '.', |
75 | 75 | $this->getOperationTypeNode($queryType, 'query') |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | $mutationType = $this->schema->getMutationType(); |
80 | - if ($mutationType && ! $mutationType instanceof ObjectType) { |
|
80 | + if ($mutationType && !$mutationType instanceof ObjectType) { |
|
81 | 81 | $this->reportError( |
82 | 82 | 'Mutation root type must be Object type if provided, it cannot be ' . Utils::printSafe($mutationType) . '.', |
83 | 83 | $this->getOperationTypeNode($mutationType, 'mutation') |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | $subscriptionType = $this->schema->getSubscriptionType(); |
88 | - if (! $subscriptionType || $subscriptionType instanceof ObjectType) { |
|
88 | + if (!$subscriptionType || $subscriptionType instanceof ObjectType) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $directives = $this->schema->getDirectives(); |
144 | 144 | foreach ($directives as $directive) { |
145 | 145 | // Ensure all directives are in fact GraphQL directives. |
146 | - if (! $directive instanceof Directive) { |
|
146 | + if (!$directive instanceof Directive) { |
|
147 | 147 | $this->reportError( |
148 | 148 | 'Expected directive but got: ' . Utils::printSafe($directive) . '.', |
149 | 149 | is_object($directive) ? $directive->astNode : null |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | { |
199 | 199 | // Ensure names are valid, however introspection types opt out. |
200 | 200 | $error = Utils::isValidNameError($node->name, $node->astNode); |
201 | - if (! $error || Introspection::isIntrospectionType($node)) { |
|
201 | + if (!$error || Introspection::isIntrospectionType($node)) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $typeMap = $this->schema->getTypeMap(); |
243 | 243 | foreach ($typeMap as $typeName => $type) { |
244 | 244 | // Ensure all provided types are in fact GraphQL type. |
245 | - if (! $type instanceof NamedType) { |
|
245 | + if (!$type instanceof NamedType) { |
|
246 | 246 | $this->reportError( |
247 | 247 | 'Expected GraphQL named type but got: ' . Utils::printSafe($type) . '.', |
248 | 248 | is_object($type) ? $type->astNode : null |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $fieldMap = $type->getFields(); |
283 | 283 | |
284 | 284 | // Objects and Interfaces both must define one or more fields. |
285 | - if (! $fieldMap) { |
|
285 | + if (!$fieldMap) { |
|
286 | 286 | $this->reportError( |
287 | 287 | sprintf('Type %s must define one or more fields.', $type->name), |
288 | 288 | $this->getAllObjectOrInterfaceNodes($type) |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | // Ensure the type is an output type |
307 | - if (! Type::isOutputType($field->getType())) { |
|
307 | + if (!Type::isOutputType($field->getType())) { |
|
308 | 308 | $this->reportError( |
309 | 309 | sprintf( |
310 | 310 | 'The type of %s.%s must be Output Type but got: %s.', |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $fieldNodes = []; |
380 | 380 | $astNodes = $this->getAllObjectOrInterfaceNodes($type); |
381 | 381 | foreach ($astNodes as $astNode) { |
382 | - if (! $astNode || ! $astNode->fields) { |
|
382 | + if (!$astNode || !$astNode->fields) { |
|
383 | 383 | continue; |
384 | 384 | } |
385 | 385 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | { |
473 | 473 | $implementedTypeNames = []; |
474 | 474 | foreach ($object->getInterfaces() as $iface) { |
475 | - if (! $iface instanceof InterfaceType) { |
|
475 | + if (!$iface instanceof InterfaceType) { |
|
476 | 476 | $this->reportError( |
477 | 477 | sprintf( |
478 | 478 | 'Type %s must only implement Interface types, it cannot implement %s.', |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | $astNodes = $this->getAllObjectOrInterfaceNodes($type); |
517 | 517 | |
518 | 518 | foreach ($astNodes as $astNode) { |
519 | - if (! $astNode || ! $astNode->interfaces) { |
|
519 | + if (!$astNode || !$astNode->interfaces) { |
|
520 | 520 | continue; |
521 | 521 | } |
522 | 522 | |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | : null; |
548 | 548 | |
549 | 549 | // Assert interface field exists on object. |
550 | - if (! $objectField) { |
|
550 | + if (!$objectField) { |
|
551 | 551 | $this->reportError( |
552 | 552 | sprintf( |
553 | 553 | 'Interface field %s.%s expected but %s does not provide it.', |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | |
563 | 563 | // Assert interface field type is satisfied by object field type, by being |
564 | 564 | // a valid subtype. (covariant) |
565 | - if (! TypeComparators::isTypeSubTypeOf( |
|
565 | + if (!TypeComparators::isTypeSubTypeOf( |
|
566 | 566 | $this->schema, |
567 | 567 | $objectField->getType(), |
568 | 568 | $ifaceField->getType() |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | } |
599 | 599 | |
600 | 600 | // Assert interface field arg exists on object field. |
601 | - if (! $objectArg) { |
|
601 | + if (!$objectArg) { |
|
602 | 602 | $this->reportError( |
603 | 603 | sprintf( |
604 | 604 | 'Interface field argument %s.%s(%s:) expected but %s.%s does not provide it.', |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | // Assert interface field arg type matches object field arg type. |
620 | 620 | // (invariant) |
621 | 621 | // TODO: change to contravariant? |
622 | - if (! TypeComparators::isEqualType($ifaceArg->getType(), $objectArg->getType())) { |
|
622 | + if (!TypeComparators::isEqualType($ifaceArg->getType(), $objectArg->getType())) { |
|
623 | 623 | $this->reportError( |
624 | 624 | sprintf( |
625 | 625 | 'Interface field argument %s.%s(%s:) expects type %s but %s.%s(%s:) is type %s.', |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | } |
654 | 654 | } |
655 | 655 | |
656 | - if ($ifaceArg || ! ($objectArg->getType() instanceof NonNull)) { |
|
656 | + if ($ifaceArg || !($objectArg->getType() instanceof NonNull)) { |
|
657 | 657 | continue; |
658 | 658 | } |
659 | 659 | |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | { |
681 | 681 | $memberTypes = $union->getTypes(); |
682 | 682 | |
683 | - if (! $memberTypes) { |
|
683 | + if (!$memberTypes) { |
|
684 | 684 | $this->reportError( |
685 | 685 | sprintf('Union type %s must define one or more member types.', $union->name), |
686 | 686 | $union->astNode |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | if ($union->astNode && $union->astNode->types) { |
723 | 723 | return array_filter( |
724 | 724 | $union->astNode->types, |
725 | - function (NamedTypeNode $value) use ($typeName) { |
|
725 | + function(NamedTypeNode $value) use ($typeName) { |
|
726 | 726 | return $value->name->value === $typeName; |
727 | 727 | } |
728 | 728 | ); |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | { |
737 | 737 | $enumValues = $enumType->getValues(); |
738 | 738 | |
739 | - if (! $enumValues) { |
|
739 | + if (!$enumValues) { |
|
740 | 740 | $this->reportError( |
741 | 741 | sprintf('Enum type %s must define one or more values.', $enumType->name), |
742 | 742 | $enumType->astNode |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | if ($enum->astNode && $enum->astNode->values) { |
778 | 778 | return array_filter( |
779 | 779 | iterator_to_array($enum->astNode->values), |
780 | - function (EnumValueDefinitionNode $value) use ($valueName) { |
|
780 | + function(EnumValueDefinitionNode $value) use ($valueName) { |
|
781 | 781 | return $value->name->value === $valueName; |
782 | 782 | } |
783 | 783 | ); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | { |
792 | 792 | $fieldMap = $inputObj->getFields(); |
793 | 793 | |
794 | - if (! $fieldMap) { |
|
794 | + if (!$fieldMap) { |
|
795 | 795 | $this->reportError( |
796 | 796 | sprintf('Input Object type %s must define one or more fields.', $inputObj->name), |
797 | 797 | $inputObj->astNode |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | Utils::getVariableType($config) |
102 | 102 | ); |
103 | 103 | Utils::invariant( |
104 | - ! $config->types || is_array($config->types) || is_callable($config->types), |
|
104 | + !$config->types || is_array($config->types) || is_callable($config->types), |
|
105 | 105 | '"types" must be array or callable if provided but got: ' . Utils::getVariableType($config->types) |
106 | 106 | ); |
107 | 107 | Utils::invariant( |
108 | - ! $config->directives || is_array($config->directives), |
|
108 | + !$config->directives || is_array($config->directives), |
|
109 | 109 | '"directives" must be Array if provided but got: ' . Utils::getVariableType($config->directives) |
110 | 110 | ); |
111 | 111 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $types = $types(); |
156 | 156 | } |
157 | 157 | |
158 | - if (! is_array($types) && ! $types instanceof \Traversable) { |
|
158 | + if (!is_array($types) && !$types instanceof \Traversable) { |
|
159 | 159 | throw new InvariantViolation(sprintf( |
160 | 160 | 'Schema types callable must return array or instance of Traversable but got: %s', |
161 | 161 | Utils::getVariableType($types) |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | foreach ($types as $index => $type) { |
166 | - if (! $type instanceof Type) { |
|
166 | + if (!$type instanceof Type) { |
|
167 | 167 | throw new InvariantViolation(sprintf( |
168 | 168 | 'Each entry of schema types must be instance of GraphQL\Type\Definition\Type but entry at %s is %s', |
169 | 169 | $index, |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function getTypeMap() |
187 | 187 | { |
188 | - if (! $this->fullyLoaded) { |
|
188 | + if (!$this->fullyLoaded) { |
|
189 | 189 | $this->resolvedTypes = $this->collectAllTypes(); |
190 | 190 | $this->fullyLoaded = true; |
191 | 191 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $typeMap = TypeInfo::extractTypes($type, $typeMap); |
204 | 204 | } |
205 | 205 | foreach ($this->getDirectives() as $directive) { |
206 | - if (! ($directive instanceof Directive)) { |
|
206 | + if (!($directive instanceof Directive)) { |
|
207 | 207 | continue; |
208 | 208 | } |
209 | 209 | |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function getType($name) |
283 | 283 | { |
284 | - if (! isset($this->resolvedTypes[$name])) { |
|
284 | + if (!isset($this->resolvedTypes[$name])) { |
|
285 | 285 | $type = $this->loadType($name); |
286 | - if (! $type) { |
|
286 | + if (!$type) { |
|
287 | 287 | return null; |
288 | 288 | } |
289 | 289 | $this->resolvedTypes[$name] = $type; |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | { |
301 | 301 | $typeLoader = $this->config->typeLoader; |
302 | 302 | |
303 | - if (! $typeLoader) { |
|
303 | + if (!$typeLoader) { |
|
304 | 304 | return $this->defaultTypeLoader($typeName); |
305 | 305 | } |
306 | 306 | |
307 | 307 | $type = $typeLoader($typeName); |
308 | 308 | |
309 | - if (! $type instanceof Type) { |
|
309 | + if (!$type instanceof Type) { |
|
310 | 310 | throw new InvariantViolation( |
311 | 311 | sprintf( |
312 | 312 | 'Type loader is expected to return valid type "%s", but it returned %s', |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | foreach ($this->getTypeMap() as $type) { |
363 | 363 | if ($type instanceof ObjectType) { |
364 | 364 | foreach ($type->getInterfaces() as $interface) { |
365 | - if (! ($interface instanceof InterfaceType)) { |
|
365 | + if (!($interface instanceof InterfaceType)) { |
|
366 | 366 | continue; |
367 | 367 | } |
368 | 368 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $type->assertValid(); |
448 | 448 | |
449 | 449 | // Make sure type loader returns the same instance as registered in other places of schema |
450 | - if (! $this->config->typeLoader) { |
|
450 | + if (!$this->config->typeLoader) { |
|
451 | 451 | continue; |
452 | 452 | } |
453 | 453 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | // Keep track of all possible types for abstract types |
40 | 40 | foreach ($this->typeMap as $typeName => $type) { |
41 | - if (! ($type instanceof ObjectType)) { |
|
41 | + if (!($type instanceof ObjectType)) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function resolvePossibleTypes(AbstractType $abstractType) |
63 | 63 | { |
64 | - if (! isset($this->typeMap[$abstractType->name])) { |
|
64 | + if (!isset($this->typeMap[$abstractType->name])) { |
|
65 | 65 | return []; |
66 | 66 | } |
67 | 67 |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function resolvePossibleTypes(AbstractType $type) |
68 | 68 | { |
69 | - if (! isset($this->possibleTypeMap[$type->name])) { |
|
69 | + if (!isset($this->possibleTypeMap[$type->name])) { |
|
70 | 70 | return []; |
71 | 71 | } |
72 | - if (! isset($this->loadedPossibleTypes[$type->name])) { |
|
72 | + if (!isset($this->loadedPossibleTypes[$type->name])) { |
|
73 | 73 | $tmp = []; |
74 | 74 | foreach ($this->possibleTypeMap[$type->name] as $typeName => $true) { |
75 | 75 | $obj = $this->resolveType($typeName); |
76 | - if (! $obj instanceof ObjectType) { |
|
76 | + if (!$obj instanceof ObjectType) { |
|
77 | 77 | throw new InvariantViolation( |
78 | 78 | sprintf( |
79 | 79 | 'Lazy Type Resolution Error: Implementation %s of interface %s is expected to be instance of ObjectType, but got %s', |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function resolveType($name) |
98 | 98 | { |
99 | - if (! isset($this->typeMap[$name])) { |
|
99 | + if (!isset($this->typeMap[$name])) { |
|
100 | 100 | return null; |
101 | 101 | } |
102 | - if (! isset($this->loadedTypes[$name])) { |
|
102 | + if (!isset($this->loadedTypes[$name])) { |
|
103 | 103 | $type = call_user_func($this->typeLoader, $name); |
104 | - if (! $type instanceof Type && $type !== null) { |
|
104 | + if (!$type instanceof Type && $type !== null) { |
|
105 | 105 | throw new InvariantViolation( |
106 | 106 | 'Lazy Type Resolution Error: Expecting GraphQL Type instance, but got ' . |
107 | 107 | Utils::getVariableType($type) |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | if (isset($node->directives) && $node->directives instanceof NodeList) { |
126 | 126 | $directiveNode = Utils::find( |
127 | 127 | $node->directives, |
128 | - function (DirectiveNode $directive) use ($directiveDef) { |
|
128 | + function(DirectiveNode $directive) use ($directiveDef) { |
|
129 | 129 | return $directive->name->value === $directiveDef->name; |
130 | 130 | } |
131 | 131 | ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | /** @var ArgumentNode[] $argNodeMap */ |
163 | 163 | $argNodeMap = $argNodes ? Utils::keyMap( |
164 | 164 | $argNodes, |
165 | - function (ArgumentNode $arg) { |
|
165 | + function(ArgumentNode $arg) { |
|
166 | 166 | return $arg->name->value; |
167 | 167 | } |
168 | 168 | ) : []; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $argType = $argDef->getType(); |
173 | 173 | $argumentNode = $argNodeMap[$name] ?? null; |
174 | 174 | |
175 | - if (! $argumentNode) { |
|
175 | + if (!$argumentNode) { |
|
176 | 176 | if ($argDef->defaultValueExists()) { |
177 | 177 | $coercedValues[$name] = $argDef->defaultValue; |
178 | 178 | } elseif ($argType instanceof NonNull) { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | return $errors |
244 | 244 | ? array_map( |
245 | - function (Throwable $error) { |
|
245 | + function(Throwable $error) { |
|
246 | 246 | return $error->getMessage(); |
247 | 247 | }, |
248 | 248 | $errors |