@@ -31,7 +31,7 @@ |
||
| 31 | 31 | $context, |
| 32 | 32 | [ |
| 33 | 33 | NodeKind::OPERATION_DEFINITION => [ |
| 34 | - 'leave' => function (OperationDefinitionNode $operationDefinition) use ($context) { |
|
| 34 | + 'leave' => function(OperationDefinitionNode $operationDefinition) use ($context) { |
|
| 35 | 35 | $maxDepth = $this->fieldDepth($operationDefinition); |
| 36 | 36 | |
| 37 | 37 | if ($maxDepth <= $this->getMaxQueryDepth()) { |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | public function getVisitor(ValidationContext $context) |
| 24 | 24 | { |
| 25 | 25 | return [ |
| 26 | - NodeKind::FIELD => function (FieldNode $node) use ($context) { |
|
| 26 | + NodeKind::FIELD => function(FieldNode $node) use ($context) { |
|
| 27 | 27 | $type = $context->getParentType(); |
| 28 | - if (! $type) { |
|
| 28 | + if (!$type) { |
|
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -85,19 +85,19 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | foreach ($schema->getPossibleTypes($type) as $possibleType) { |
| 87 | 87 | $fields = $possibleType->getFields(); |
| 88 | - if (! isset($fields[$fieldName])) { |
|
| 88 | + if (!isset($fields[$fieldName])) { |
|
| 89 | 89 | continue; |
| 90 | 90 | } |
| 91 | 91 | // This object type defines this field. |
| 92 | 92 | $suggestedObjectTypes[] = $possibleType->name; |
| 93 | 93 | foreach ($possibleType->getInterfaces() as $possibleInterface) { |
| 94 | 94 | $fields = $possibleInterface->getFields(); |
| 95 | - if (! isset($fields[$fieldName])) { |
|
| 95 | + if (!isset($fields[$fieldName])) { |
|
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | // This interface type defines this field. |
| 99 | 99 | $interfaceUsageCount[$possibleInterface->name] = |
| 100 | - ! isset($interfaceUsageCount[$possibleInterface->name]) |
|
| 100 | + !isset($interfaceUsageCount[$possibleInterface->name]) |
|
| 101 | 101 | ? 0 |
| 102 | 102 | : $interfaceUsageCount[$possibleInterface->name] + 1; |
| 103 | 103 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $suggestions = Utils::quotedOrList($suggestedTypeNames); |
| 157 | 157 | |
| 158 | 158 | $message .= sprintf(' Did you mean to use an inline fragment on %s?', $suggestions); |
| 159 | - } elseif (! empty($suggestedFieldNames)) { |
|
| 159 | + } elseif (!empty($suggestedFieldNames)) { |
|
| 160 | 160 | $suggestions = Utils::quotedOrList($suggestedFieldNames); |
| 161 | 161 | |
| 162 | 162 | $message .= sprintf(' Did you mean %s?', $suggestions); |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | return $this->invokeIfNeeded( |
| 32 | 32 | $context, |
| 33 | 33 | [ |
| 34 | - NodeKind::FIELD => static function (FieldNode $node) use ($context) { |
|
| 34 | + NodeKind::FIELD => static function(FieldNode $node) use ($context) { |
|
| 35 | 35 | if ($node->name->value !== '__type' && $node->name->value !== '__schema') { |
| 36 | 36 | return; |
| 37 | 37 | } |
@@ -26,18 +26,18 @@ discard block |
||
| 26 | 26 | $this->fragmentDefs = []; |
| 27 | 27 | |
| 28 | 28 | return [ |
| 29 | - NodeKind::OPERATION_DEFINITION => function ($node) { |
|
| 29 | + NodeKind::OPERATION_DEFINITION => function($node) { |
|
| 30 | 30 | $this->operationDefs[] = $node; |
| 31 | 31 | |
| 32 | 32 | return Visitor::skipNode(); |
| 33 | 33 | }, |
| 34 | - NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $def) { |
|
| 34 | + NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) { |
|
| 35 | 35 | $this->fragmentDefs[] = $def; |
| 36 | 36 | |
| 37 | 37 | return Visitor::skipNode(); |
| 38 | 38 | }, |
| 39 | 39 | NodeKind::DOCUMENT => [ |
| 40 | - 'leave' => function () use ($context) { |
|
| 40 | + 'leave' => function() use ($context) { |
|
| 41 | 41 | $fragmentNameUsed = []; |
| 42 | 42 | |
| 43 | 43 | foreach ($this->operationDefs as $operation) { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | foreach ($this->fragmentDefs as $fragmentDef) { |
| 50 | 50 | $fragName = $fragmentDef->name->value; |
| 51 | - if (! empty($fragmentNameUsed[$fragName])) { |
|
| 51 | + if (!empty($fragmentNameUsed[$fragName])) { |
|
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | foreach ($definedDirectives as $directive) { |
| 40 | 40 | $directiveArgs[$directive->name] = array_map( |
| 41 | - static function (FieldArgument $arg) : string { |
|
| 41 | + static function(FieldArgument $arg) : string { |
|
| 42 | 42 | return $arg->name; |
| 43 | 43 | }, |
| 44 | 44 | $directive->args |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $astDefinitions = $context->getDocument()->definitions; |
| 49 | 49 | foreach ($astDefinitions as $def) { |
| 50 | - if (! ($def instanceof DirectiveDefinitionNode)) { |
|
| 50 | + if (!($def instanceof DirectiveDefinitionNode)) { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $arguments = iterator_to_array($arguments->getIterator()); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $directiveArgs[$name] = array_map(static function (InputValueDefinitionNode $arg) : string { |
|
| 62 | + $directiveArgs[$name] = array_map(static function(InputValueDefinitionNode $arg) : string { |
|
| 63 | 63 | return $arg->name->value; |
| 64 | 64 | }, $arguments); |
| 65 | 65 | } else { |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return [ |
| 71 | - NodeKind::DIRECTIVE => static function (DirectiveNode $directiveNode) use ($directiveArgs, $context) { |
|
| 71 | + NodeKind::DIRECTIVE => static function(DirectiveNode $directiveNode) use ($directiveArgs, $context) { |
|
| 72 | 72 | $directiveName = $directiveNode->name->value; |
| 73 | 73 | $knownArgs = $directiveArgs[$directiveName] ?? null; |
| 74 | 74 | |
| 75 | - if ($directiveNode->arguments === null || ! $knownArgs) { |
|
| 75 | + if ($directiveNode->arguments === null || !$knownArgs) { |
|
| 76 | 76 | return; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -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(); |
@@ -40,18 +40,18 @@ |
||
| 40 | 40 | |
| 41 | 41 | return [ |
| 42 | 42 | NodeKind::OBJECT => [ |
| 43 | - 'enter' => function () { |
|
| 43 | + 'enter' => function() { |
|
| 44 | 44 | $this->knownNameStack[] = $this->knownNames; |
| 45 | 45 | $this->knownNames = []; |
| 46 | 46 | }, |
| 47 | - 'leave' => function () { |
|
| 47 | + 'leave' => function() { |
|
| 48 | 48 | $this->knownNames = array_pop($this->knownNameStack); |
| 49 | 49 | }, |
| 50 | 50 | ], |
| 51 | - NodeKind::OBJECT_FIELD => function (ObjectFieldNode $node) use ($context) { |
|
| 51 | + NodeKind::OBJECT_FIELD => function(ObjectFieldNode $node) use ($context) { |
|
| 52 | 52 | $fieldName = $node->name->value; |
| 53 | 53 | |
| 54 | - if (! empty($this->knownNames[$fieldName])) { |
|
| 54 | + if (!empty($this->knownNames[$fieldName])) { |
|
| 55 | 55 | $context->reportError(new Error( |
| 56 | 56 | self::duplicateInputFieldMessage($fieldName), |
| 57 | 57 | [$this->knownNames[$fieldName], $node->name] |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $this->knownOperationNames = []; |
| 23 | 23 | |
| 24 | 24 | return [ |
| 25 | - NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use ($context) { |
|
| 25 | + NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) { |
|
| 26 | 26 | $operationName = $node->name; |
| 27 | 27 | |
| 28 | 28 | if ($operationName) { |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | return Visitor::skipNode(); |
| 40 | 40 | }, |
| 41 | - NodeKind::FRAGMENT_DEFINITION => static function () { |
|
| 41 | + NodeKind::FRAGMENT_DEFINITION => static function() { |
|
| 42 | 42 | return Visitor::skipNode(); |
| 43 | 43 | }, |
| 44 | 44 | ]; |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | $astDefinition = $context->getDocument()->definitions; |
| 73 | 73 | |
| 74 | 74 | foreach ($astDefinition as $def) { |
| 75 | - if (! ($def instanceof DirectiveDefinitionNode)) { |
|
| 75 | + if (!($def instanceof DirectiveDefinitionNode)) { |
|
| 76 | 76 | continue; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $locationsMap[$def->name->value] = array_map( |
| 80 | - static function ($name) { |
|
| 80 | + static function($name) { |
|
| 81 | 81 | return $name->value; |
| 82 | 82 | }, |
| 83 | 83 | $def->locations |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return [ |
| 88 | - NodeKind::DIRECTIVE => function ( |
|
| 88 | + NodeKind::DIRECTIVE => function( |
|
| 89 | 89 | DirectiveNode $node, |
| 90 | 90 | $key, |
| 91 | 91 | $parent, |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $name = $node->name->value; |
| 99 | 99 | $locations = $locationsMap[$name] ?? null; |
| 100 | 100 | |
| 101 | - if (! $locations) { |
|
| 101 | + if (!$locations) { |
|
| 102 | 102 | $context->reportError(new Error( |
| 103 | 103 | self::unknownDirectiveMessage($name), |
| 104 | 104 | [$node] |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $candidateLocation = $this->getDirectiveLocationForASTPath($ancestors); |
| 111 | 111 | |
| 112 | - if (! $candidateLocation || in_array($candidateLocation, $locations, true)) { |
|
| 112 | + if (!$candidateLocation || in_array($candidateLocation, $locations, true)) { |
|
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | 115 | $context->reportError( |