@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | |
46 | 46 | foreach ($definedDirectives as $directive) { |
47 | 47 | $requiredArgsMap[$directive->name] = Utils::keyMap( |
48 | - array_filter($directive->args, static function (FieldArgument $arg) : bool { |
|
49 | - return $arg->getType() instanceof NonNull && ! isset($arg->defaultValue); |
|
48 | + array_filter($directive->args, static function(FieldArgument $arg) : bool { |
|
49 | + return $arg->getType() instanceof NonNull && !isset($arg->defaultValue); |
|
50 | 50 | }), |
51 | - static function (FieldArgument $arg) : string { |
|
51 | + static function(FieldArgument $arg) : string { |
|
52 | 52 | return $arg->name; |
53 | 53 | } |
54 | 54 | ); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $astDefinition = $context->getDocument()->definitions; |
58 | 58 | foreach ($astDefinition as $def) { |
59 | - if (! ($def instanceof DirectiveDefinitionNode)) { |
|
59 | + if (!($def instanceof DirectiveDefinitionNode)) { |
|
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
@@ -70,32 +70,32 @@ discard block |
||
70 | 70 | |
71 | 71 | $requiredArgsMap[$def->name->value] = Utils::keyMap( |
72 | 72 | $arguments |
73 | - ? array_filter($arguments, static function (Node $argument) : bool { |
|
73 | + ? array_filter($arguments, static function(Node $argument) : bool { |
|
74 | 74 | return $argument instanceof NonNullTypeNode && |
75 | 75 | ( |
76 | - ! isset($argument->defaultValue) || |
|
76 | + !isset($argument->defaultValue) || |
|
77 | 77 | $argument->defaultValue === null |
78 | 78 | ); |
79 | 79 | }) |
80 | 80 | : [], |
81 | - static function (NamedTypeNode $argument) : string { |
|
81 | + static function(NamedTypeNode $argument) : string { |
|
82 | 82 | return $argument->name->value; |
83 | 83 | } |
84 | 84 | ); |
85 | 85 | } |
86 | 86 | |
87 | 87 | return [ |
88 | - NodeKind::DIRECTIVE => static function (DirectiveNode $directiveNode) use ($requiredArgsMap, $context) { |
|
88 | + NodeKind::DIRECTIVE => static function(DirectiveNode $directiveNode) use ($requiredArgsMap, $context) { |
|
89 | 89 | $directiveName = $directiveNode->name->value; |
90 | 90 | $requiredArgs = $requiredArgsMap[$directiveName] ?? null; |
91 | - if (! $requiredArgs) { |
|
91 | + if (!$requiredArgs) { |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $argNodes = $directiveNode->arguments ?: []; |
96 | 96 | $argNodeMap = Utils::keyMap( |
97 | 97 | $argNodes, |
98 | - static function (ArgumentNode $arg) : string { |
|
98 | + static function(ArgumentNode $arg) : string { |
|
99 | 99 | return $arg->name->value; |
100 | 100 | } |
101 | 101 | ); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return $this->invokeIfNeeded( |
61 | 61 | $context, |
62 | 62 | [ |
63 | - NodeKind::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) { |
|
63 | + NodeKind::SELECTION_SET => function(SelectionSetNode $selectionSet) use ($context) { |
|
64 | 64 | $this->fieldNodeAndDefs = $this->collectFieldASTsAndDefs( |
65 | 65 | $context, |
66 | 66 | $context->getParentType(), |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | $this->fieldNodeAndDefs |
70 | 70 | ); |
71 | 71 | }, |
72 | - NodeKind::VARIABLE_DEFINITION => function ($def) { |
|
72 | + NodeKind::VARIABLE_DEFINITION => function($def) { |
|
73 | 73 | $this->variableDefs[] = $def; |
74 | 74 | |
75 | 75 | return Visitor::skipNode(); |
76 | 76 | }, |
77 | 77 | NodeKind::OPERATION_DEFINITION => [ |
78 | - 'leave' => function (OperationDefinitionNode $operationDefinition) use ($context, &$complexity) { |
|
78 | + 'leave' => function(OperationDefinitionNode $operationDefinition) use ($context, &$complexity) { |
|
79 | 79 | $errors = $context->getErrors(); |
80 | 80 | |
81 | - if (! empty($errors)) { |
|
81 | + if (!empty($errors)) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $this->variableDefs, |
192 | 192 | $this->getRawVariableValues() |
193 | 193 | ); |
194 | - if (! empty($errors)) { |
|
194 | + if (!empty($errors)) { |
|
195 | 195 | throw new Error(implode( |
196 | 196 | "\n\n", |
197 | 197 | array_map( |
198 | - static function ($error) { |
|
198 | + static function($error) { |
|
199 | 199 | return $error->getMessage(); |
200 | 200 | }, |
201 | 201 | $errors |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | /** @var bool $directiveArgsIf */ |
208 | 208 | $directiveArgsIf = Values::getArgumentValues($directive, $directiveNode, $variableValues)['if']; |
209 | 209 | |
210 | - return ! $directiveArgsIf; |
|
210 | + return !$directiveArgsIf; |
|
211 | 211 | } |
212 | 212 | if ($directiveNode->name->value === Directive::SKIP_NAME) { |
213 | 213 | $directive = Directive::skipDirective(); |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | $rawVariableValues |
250 | 250 | ); |
251 | 251 | |
252 | - if (! empty($errors)) { |
|
252 | + if (!empty($errors)) { |
|
253 | 253 | throw new Error(implode( |
254 | 254 | "\n\n", |
255 | 255 | array_map( |
256 | - static function ($error) { |
|
256 | + static function($error) { |
|
257 | 257 | return $error->getMessage(); |
258 | 258 | }, |
259 | 259 | $errors |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $schemaDefinitionsCount = 0; |
42 | 42 | |
43 | 43 | return [ |
44 | - NodeKind::SCHEMA_DEFINITION => static function (SchemaDefinitionNode $node) use ($alreadyDefined, $context, &$schemaDefinitionsCount) { |
|
44 | + NodeKind::SCHEMA_DEFINITION => static function(SchemaDefinitionNode $node) use ($alreadyDefined, $context, &$schemaDefinitionsCount) { |
|
45 | 45 | if ($alreadyDefined !== false) { |
46 | 46 | $context->reportError(new Error(self::canNotDefineSchemaWithinExtensionMessage(), $node)); |
47 | 47 |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | { |
33 | 33 | return [ |
34 | 34 | NodeKind::OPERATION_DEFINITION => [ |
35 | - 'enter' => function () { |
|
35 | + 'enter' => function() { |
|
36 | 36 | $this->varDefMap = []; |
37 | 37 | }, |
38 | - 'leave' => function (OperationDefinitionNode $operation) use ($context) { |
|
38 | + 'leave' => function(OperationDefinitionNode $operation) use ($context) { |
|
39 | 39 | $usages = $context->getRecursiveVariableUsages($operation); |
40 | 40 | |
41 | 41 | foreach ($usages as $usage) { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $schema = $context->getSchema(); |
58 | 58 | $varType = TypeInfo::typeFromAST($schema, $varDef->type); |
59 | 59 | |
60 | - if (! $varType || $this->allowedVariableUsage($schema, $varType, $varDef->defaultValue, $type, $defaultValue)) { |
|
60 | + if (!$varType || $this->allowedVariableUsage($schema, $varType, $varDef->defaultValue, $type, $defaultValue)) { |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | }, |
70 | 70 | ], |
71 | - NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $varDefNode) { |
|
71 | + NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefNode) { |
|
72 | 72 | $this->varDefMap[$varDefNode->variable->name->value] = $varDefNode; |
73 | 73 | }, |
74 | 74 | ]; |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | */ |
101 | 101 | private function allowedVariableUsage(Schema $schema, Type $varType, $varDefaultValue, Type $locationType, $locationDefaultValue) : bool |
102 | 102 | { |
103 | - if ($locationType instanceof NonNull && ! $varType instanceof NonNull) { |
|
104 | - $hasNonNullVariableDefaultValue = $varDefaultValue && ! $varDefaultValue instanceof NullValueNode; |
|
105 | - $hasLocationDefaultValue = ! Utils::isInvalid($locationDefaultValue); |
|
106 | - if (! $hasNonNullVariableDefaultValue && ! $hasLocationDefaultValue) { |
|
103 | + if ($locationType instanceof NonNull && !$varType instanceof NonNull) { |
|
104 | + $hasNonNullVariableDefaultValue = $varDefaultValue && !$varDefaultValue instanceof NullValueNode; |
|
105 | + $hasLocationDefaultValue = !Utils::isInvalid($locationDefaultValue); |
|
106 | + if (!$hasNonNullVariableDefaultValue && !$hasLocationDefaultValue) { |
|
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | $nullableLocationType = $locationType->getWrappedType(); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function getVisitor(ValidationContext $context) |
29 | 29 | { |
30 | 30 | return [ |
31 | - NodeKind::ARGUMENT => static function (ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) { |
|
31 | + NodeKind::ARGUMENT => static function(ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) { |
|
32 | 32 | $argDef = $context->getArgument(); |
33 | 33 | if ($argDef !== null) { |
34 | 34 | return; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | Utils::suggestionList( |
49 | 49 | $node->name->value, |
50 | 50 | array_map( |
51 | - static function ($arg) { |
|
51 | + static function($arg) { |
|
52 | 52 | return $arg->name; |
53 | 53 | }, |
54 | 54 | $fieldDef->args |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | Utils::suggestionList( |
69 | 69 | $node->name->value, |
70 | 70 | array_map( |
71 | - static function ($arg) { |
|
71 | + static function($arg) { |
|
72 | 72 | return $arg->name; |
73 | 73 | }, |
74 | 74 | $directive->args |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public static function unknownArgMessage($argName, $fieldName, $typeName, array $suggestedArgs) |
90 | 90 | { |
91 | 91 | $message = sprintf('Unknown argument "%s" on field "%s" of type "%s".', $argName, $fieldName, $typeName); |
92 | - if (! empty($suggestedArgs)) { |
|
92 | + if (!empty($suggestedArgs)) { |
|
93 | 93 | $message .= sprintf(' Did you mean %s?', Utils::quotedOrList($suggestedArgs)); |
94 | 94 | } |
95 | 95 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public static function unknownDirectiveArgMessage($argName, $directiveName, array $suggestedArgs) |
103 | 103 | { |
104 | 104 | $message = sprintf('Unknown argument "%s" on directive "@%s".', $argName, $directiveName); |
105 | - if (! empty($suggestedArgs)) { |
|
105 | + if (!empty($suggestedArgs)) { |
|
106 | 106 | $message .= sprintf(' Did you mean %s?', Utils::quotedOrList($suggestedArgs)); |
107 | 107 | } |
108 | 108 |
@@ -27,8 +27,8 @@ |
||
27 | 27 | public function getASTVisitor(ASTValidationContext $context) |
28 | 28 | { |
29 | 29 | return [ |
30 | - 'enter' => static function (Node $node) use ($context) { |
|
31 | - if (! isset($node->directives)) { |
|
30 | + 'enter' => static function(Node $node) use ($context) { |
|
31 | + if (!isset($node->directives)) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | { |
20 | 20 | return [ |
21 | 21 | NodeKind::FIELD => [ |
22 | - 'leave' => static function (FieldNode $fieldNode) use ($context) { |
|
22 | + 'leave' => static function(FieldNode $fieldNode) use ($context) { |
|
23 | 23 | $fieldDef = $context->getFieldDef(); |
24 | 24 | |
25 | - if (! $fieldDef) { |
|
25 | + if (!$fieldDef) { |
|
26 | 26 | return Visitor::skipNode(); |
27 | 27 | } |
28 | 28 | $argNodes = $fieldNode->arguments ?: []; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | foreach ($fieldDef->args as $argDef) { |
35 | 35 | $argNode = $argNodeMap[$argDef->name] ?? null; |
36 | - if ($argNode || (! ($argDef->getType() instanceof NonNull)) || $argDef->defaultValueExists()) { |
|
36 | + if ($argNode || (!($argDef->getType() instanceof NonNull)) || $argDef->defaultValueExists()) { |
|
37 | 37 | continue; |
38 | 38 | } |
39 | 39 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | }, |
46 | 46 | ], |
47 | 47 | NodeKind::DIRECTIVE => [ |
48 | - 'leave' => static function (DirectiveNode $directiveNode) use ($context) { |
|
48 | + 'leave' => static function(DirectiveNode $directiveNode) use ($context) { |
|
49 | 49 | $directiveDef = $context->getDirective(); |
50 | - if (! $directiveDef) { |
|
50 | + if (!$directiveDef) { |
|
51 | 51 | return Visitor::skipNode(); |
52 | 52 | } |
53 | 53 | $argNodes = $directiveNode->arguments ?: []; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | foreach ($directiveDef->args as $argDef) { |
60 | 60 | $argNode = $argNodeMap[$argDef->name] ?? null; |
61 | - if ($argNode || (! ($argDef->getType() instanceof NonNull)) || $argDef->defaultValueExists()) { |
|
61 | + if ($argNode || (!($argDef->getType() instanceof NonNull)) || $argDef->defaultValueExists()) { |
|
62 | 62 | continue; |
63 | 63 | } |
64 | 64 |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $this->spreadPathIndexByName = []; |
42 | 42 | |
43 | 43 | return [ |
44 | - NodeKind::OPERATION_DEFINITION => static function () { |
|
44 | + NodeKind::OPERATION_DEFINITION => static function() { |
|
45 | 45 | return Visitor::skipNode(); |
46 | 46 | }, |
47 | - NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) { |
|
47 | + NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) { |
|
48 | 48 | $this->detectCycleRecursive($node, $context); |
49 | 49 | |
50 | 50 | return Visitor::skipNode(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | private function detectCycleRecursive(FragmentDefinitionNode $fragment, ValidationContext $context) |
56 | 56 | { |
57 | - if (! empty($this->visitedFrags[$fragment->name->value])) { |
|
57 | + if (!empty($this->visitedFrags[$fragment->name->value])) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | $cyclePath = array_slice($this->spreadPath, $cycleIndex); |
85 | - $fragmentNames = Utils::map(array_slice($cyclePath, 0, -1), static function ($s) { |
|
85 | + $fragmentNames = Utils::map(array_slice($cyclePath, 0, -1), static function($s) { |
|
86 | 86 | return $s->name->value; |
87 | 87 | }); |
88 | 88 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return sprintf( |
106 | 106 | 'Cannot spread fragment "%s" within itself%s.', |
107 | 107 | $fragName, |
108 | - ! empty($spreadNames) ? ' via ' . implode(', ', $spreadNames) : '' |
|
108 | + !empty($spreadNames) ? ' via ' . implode(', ', $spreadNames) : '' |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $this->cachedFieldsAndFragmentNames = new SplObjectStorage(); |
61 | 61 | |
62 | 62 | return [ |
63 | - NodeKind::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) { |
|
63 | + NodeKind::SELECTION_SET => function(SelectionSetNode $selectionSet) use ($context) { |
|
64 | 64 | $conflicts = $this->findConflictsWithinSelectionSet( |
65 | 65 | $context, |
66 | 66 | $context->getParentType(), |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | $responseName = $selection->alias ? $selection->alias->value : $fieldName; |
261 | 261 | |
262 | - if (! isset($astAndDefs[$responseName])) { |
|
262 | + if (!isset($astAndDefs[$responseName])) { |
|
263 | 263 | $astAndDefs[$responseName] = []; |
264 | 264 | } |
265 | 265 | $astAndDefs[$responseName][] = [$parentType, $selection, $fieldDef]; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $fields[$i], |
319 | 319 | $fields[$j] |
320 | 320 | ); |
321 | - if (! $conflict) { |
|
321 | + if (!$conflict) { |
|
322 | 322 | continue; |
323 | 323 | } |
324 | 324 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $type1 = $def1 === null ? null : $def1->getType(); |
370 | 370 | $type2 = $def2 === null ? null : $def2->getType(); |
371 | 371 | |
372 | - if (! $areMutuallyExclusive) { |
|
372 | + if (!$areMutuallyExclusive) { |
|
373 | 373 | // Two aliases must refer to the same field. |
374 | 374 | $name1 = $ast1->name->value; |
375 | 375 | $name2 = $ast2->name->value; |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | ]; |
382 | 382 | } |
383 | 383 | |
384 | - if (! $this->sameArguments($ast1->arguments ?: [], $ast2->arguments ?: [])) { |
|
384 | + if (!$this->sameArguments($ast1->arguments ?: [], $ast2->arguments ?: [])) { |
|
385 | 385 | return [ |
386 | 386 | [$responseName, 'they have differing arguments'], |
387 | 387 | [$ast1], |
@@ -443,11 +443,11 @@ discard block |
||
443 | 443 | break; |
444 | 444 | } |
445 | 445 | } |
446 | - if (! $argument2) { |
|
446 | + if (!$argument2) { |
|
447 | 447 | return false; |
448 | 448 | } |
449 | 449 | |
450 | - if (! $this->sameValue($argument1->value, $argument2->value)) { |
|
450 | + if (!$this->sameValue($argument1->value, $argument2->value)) { |
|
451 | 451 | return false; |
452 | 452 | } |
453 | 453 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | */ |
461 | 461 | private function sameValue(Node $value1, Node $value2) |
462 | 462 | { |
463 | - return (! $value1 && ! $value2) || (Printer::doPrint($value1) === Printer::doPrint($value2)); |
|
463 | + return (!$value1 && !$value2) || (Printer::doPrint($value1) === Printer::doPrint($value2)); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | // maps, each field from the first field map must be compared to every field |
616 | 616 | // in the second field map to find potential conflicts. |
617 | 617 | foreach ($fieldMap1 as $responseName => $fields1) { |
618 | - if (! isset($fieldMap2[$responseName])) { |
|
618 | + if (!isset($fieldMap2[$responseName])) { |
|
619 | 619 | continue; |
620 | 620 | } |
621 | 621 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | $fields1[$i], |
632 | 632 | $fields2[$j] |
633 | 633 | ); |
634 | - if (! $conflict) { |
|
634 | + if (!$conflict) { |
|
635 | 635 | continue; |
636 | 636 | } |
637 | 637 | |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $comparedFragments[$fragmentName] = true; |
666 | 666 | |
667 | 667 | $fragment = $context->getFragment($fragmentName); |
668 | - if (! $fragment) { |
|
668 | + if (!$fragment) { |
|
669 | 669 | return; |
670 | 670 | } |
671 | 671 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | |
766 | 766 | $fragment1 = $context->getFragment($fragmentName1); |
767 | 767 | $fragment2 = $context->getFragment($fragmentName2); |
768 | - if (! $fragment1 || ! $fragment2) { |
|
768 | + if (!$fragment1 || !$fragment2) { |
|
769 | 769 | return; |
770 | 770 | } |
771 | 771 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | [ |
839 | 839 | $responseName, |
840 | 840 | array_map( |
841 | - static function ($conflict) { |
|
841 | + static function($conflict) { |
|
842 | 842 | return $conflict[0]; |
843 | 843 | }, |
844 | 844 | $conflicts |
@@ -846,14 +846,14 @@ discard block |
||
846 | 846 | ], |
847 | 847 | array_reduce( |
848 | 848 | $conflicts, |
849 | - static function ($allFields, $conflict) { |
|
849 | + static function($allFields, $conflict) { |
|
850 | 850 | return array_merge($allFields, $conflict[1]); |
851 | 851 | }, |
852 | 852 | [$ast1] |
853 | 853 | ), |
854 | 854 | array_reduce( |
855 | 855 | $conflicts, |
856 | - static function ($allFields, $conflict) { |
|
856 | + static function($allFields, $conflict) { |
|
857 | 857 | return array_merge($allFields, $conflict[2]); |
858 | 858 | }, |
859 | 859 | [$ast2] |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | { |
881 | 881 | if (is_array($reason)) { |
882 | 882 | $tmp = array_map( |
883 | - static function ($tmp) { |
|
883 | + static function($tmp) { |
|
884 | 884 | [$responseName, $subReason] = $tmp; |
885 | 885 | |
886 | 886 | $reasonMessage = self::reasonMessage($subReason); |