Fix CS in src/Validator

This commit is contained in:
Simon Podlipsky 2018-09-26 11:01:29 +02:00
parent e664c4455e
commit dd4a5076f6
No known key found for this signature in database
GPG Key ID: 725C2BD962B42663
26 changed files with 96 additions and 71 deletions

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace GraphQL\Validator;
use Exception;
use GraphQL\Error\Error;
use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\Visitor;
@ -41,6 +42,7 @@ use GraphQL\Validator\Rules\ValuesOfCorrectType;
use GraphQL\Validator\Rules\VariablesAreInputTypes;
use GraphQL\Validator\Rules\VariablesDefaultValueAllowed;
use GraphQL\Validator\Rules\VariablesInAllowedPosition;
use Throwable;
use function array_filter;
use function array_merge;
use function count;
@ -82,9 +84,11 @@ class DocumentValidator
/**
* Primary method for query validation. See class description for details.
*
* @api
* @param ValidationRule[]|null $rules
*
* @return Error[]
*
* @api
*/
public static function validate(
Schema $schema,
@ -109,8 +113,9 @@ class DocumentValidator
/**
* Returns all global validation rules.
*
* @api
* @return ValidationRule[]
*
* @api
*/
public static function allRules()
{
@ -183,6 +188,7 @@ class DocumentValidator
* while maintaining the visitor skip and break API.
*
* @param ValidationRule[] $rules
*
* @return Error[]
*/
public static function visitUsingRules(Schema $schema, TypeInfo $typeInfo, DocumentNode $documentNode, array $rules)
@ -203,9 +209,11 @@ class DocumentValidator
*
* $rule = DocumentValidator::getRule(GraphQL\Validator\Rules\QueryComplexity::class);
*
* @api
* @param string $name
*
* @return ValidationRule
*
* @api
*/
public static function getRule($name)
{
@ -235,11 +243,11 @@ class DocumentValidator
return is_array($value)
? count(array_filter(
$value,
function ($item) {
return $item instanceof \Exception || $item instanceof \Throwable;
static function ($item) {
return $item instanceof Exception || $item instanceof Throwable;
}
)) === count($value)
: ($value instanceof \Exception || $value instanceof \Throwable);
: ($value instanceof Exception || $value instanceof Throwable);
}
public static function append(&$arr, $items)
@ -259,6 +267,7 @@ class DocumentValidator
* Deprecated. Rely on validation for documents containing literal values.
*
* @deprecated
*
* @return Error[]
*/
public static function isValidLiteralValue(Type $type, $valueNode)

View File

@ -31,7 +31,7 @@ class DisableIntrospection extends QuerySecurityRule
return $this->invokeIfNeeded(
$context,
[
NodeKind::FIELD => function (FieldNode $node) use ($context) {
NodeKind::FIELD => static function (FieldNode $node) use ($context) {
if ($node->name->value !== '__type' && $node->name->value !== '__schema') {
return;
}

View File

@ -25,7 +25,7 @@ class ExecutableDefinitions extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::DOCUMENT => function (DocumentNode $node) use ($context) {
NodeKind::DOCUMENT => static function (DocumentNode $node) use ($context) {
/** @var Node $definition */
foreach ($node->definitions as $definition) {
if ($definition instanceof OperationDefinitionNode ||

View File

@ -74,6 +74,7 @@ class FieldsOnCorrectType extends ValidationRule
*
* @param ObjectType|InterfaceType $type
* @param string $fieldName
*
* @return string[]
*/
private function getSuggestedTypeNames(Schema $schema, $type, $fieldName)
@ -120,6 +121,7 @@ class FieldsOnCorrectType extends ValidationRule
*
* @param ObjectType|InterfaceType $type
* @param string $fieldName
*
* @return array|string[]
*/
private function getSuggestedFieldNames(Schema $schema, $type, $fieldName)
@ -139,6 +141,7 @@ class FieldsOnCorrectType extends ValidationRule
* @param string $type
* @param string[] $suggestedTypeNames
* @param string[] $suggestedFieldNames
*
* @return string
*/
public static function undefinedFieldMessage(

View File

@ -19,7 +19,7 @@ class FragmentsOnCompositeTypes extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::INLINE_FRAGMENT => function (InlineFragmentNode $node) use ($context) {
NodeKind::INLINE_FRAGMENT => static function (InlineFragmentNode $node) use ($context) {
if (! $node->typeCondition) {
return;
}
@ -34,7 +34,7 @@ class FragmentsOnCompositeTypes extends ValidationRule
[$node->typeCondition]
));
},
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
NodeKind::FRAGMENT_DEFINITION => static function (FragmentDefinitionNode $node) use ($context) {
$type = TypeInfo::typeFromAST($context->getSchema(), $node->typeCondition);
if (! $type || Type::isCompositeType($type)) {

View File

@ -26,7 +26,7 @@ class KnownArgumentNames extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::ARGUMENT => function (ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) {
NodeKind::ARGUMENT => static function (ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) {
/** @var NodeList|Node[] $ancestors */
$argDef = $context->getArgument();
if ($argDef !== null) {
@ -46,7 +46,7 @@ class KnownArgumentNames extends ValidationRule
Utils::suggestionList(
$node->name->value,
array_map(
function ($arg) {
static function ($arg) {
return $arg->name;
},
$fieldDef->args
@ -66,7 +66,7 @@ class KnownArgumentNames extends ValidationRule
Utils::suggestionList(
$node->name->value,
array_map(
function ($arg) {
static function ($arg) {
return $arg->name;
},
$directive->args

View File

@ -37,7 +37,7 @@ class KnownDirectives extends ValidationRule
continue;
}
$locationsMap[$def->name->value] = array_map(function ($name) {
$locationsMap[$def->name->value] = array_map(static function ($name) {
return $name->value;
}, $def->locations);
}

View File

@ -15,7 +15,7 @@ class KnownFragmentNames extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::FRAGMENT_SPREAD => function (FragmentSpreadNode $node) use ($context) {
NodeKind::FRAGMENT_SPREAD => static function (FragmentSpreadNode $node) use ($context) {
$fragmentName = $node->name->value;
$fragment = $context->getFragment($fragmentName);
if ($fragment) {

View File

@ -23,7 +23,7 @@ class KnownTypeNames extends ValidationRule
{
public function getVisitor(ValidationContext $context)
{
$skip = function () {
$skip = static function () {
return Visitor::skipNode();
};
@ -35,7 +35,7 @@ class KnownTypeNames extends ValidationRule
NodeKind::INTERFACE_TYPE_DEFINITION => $skip,
NodeKind::UNION_TYPE_DEFINITION => $skip,
NodeKind::INPUT_OBJECT_TYPE_DEFINITION => $skip,
NodeKind::NAMED_TYPE => function (NamedTypeNode $node) use ($context) {
NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) use ($context) {
$schema = $context->getSchema();
$typeName = $node->name->value;
$type = $schema->getType($typeName);

View File

@ -26,17 +26,17 @@ class LoneAnonymousOperation extends ValidationRule
$operationCount = 0;
return [
NodeKind::DOCUMENT => function (DocumentNode $node) use (&$operationCount) {
NodeKind::DOCUMENT => static function (DocumentNode $node) use (&$operationCount) {
$tmp = Utils::filter(
$node->definitions,
function (Node $definition) {
static function (Node $definition) {
return $definition->kind === NodeKind::OPERATION_DEFINITION;
}
);
$operationCount = count($tmp);
},
NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use (
NodeKind::OPERATION_DEFINITION => static function (OperationDefinitionNode $node) use (
&$operationCount,
$context
) {

View File

@ -43,7 +43,7 @@ class NoFragmentCycles extends ValidationRule
$this->spreadPathIndexByName = [];
return [
NodeKind::OPERATION_DEFINITION => function () {
NodeKind::OPERATION_DEFINITION => static function () {
return Visitor::skipNode();
},
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
@ -98,7 +98,7 @@ class NoFragmentCycles extends ValidationRule
$spreadName,
Utils::map(
$cyclePath,
function ($s) {
static function ($s) {
return $s->name->value;
}
)

View File

@ -25,10 +25,10 @@ class NoUndefinedVariables extends ValidationRule
return [
NodeKind::OPERATION_DEFINITION => [
'enter' => function () use (&$variableNameDefined) {
'enter' => static function () use (&$variableNameDefined) {
$variableNameDefined = [];
},
'leave' => function (OperationDefinitionNode $operation) use (&$variableNameDefined, $context) {
'leave' => static function (OperationDefinitionNode $operation) use (&$variableNameDefined, $context) {
$usages = $context->getRecursiveVariableUsages($operation);
foreach ($usages as $usage) {
@ -49,7 +49,7 @@ class NoUndefinedVariables extends ValidationRule
}
},
],
NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $def) use (&$variableNameDefined) {
NodeKind::VARIABLE_DEFINITION => static function (VariableDefinitionNode $def) use (&$variableNameDefined) {
$variableNameDefined[$def->variable->name->value] = true;
},
];

View File

@ -24,6 +24,7 @@ use GraphQL\Type\Definition\Type;
use GraphQL\Utils\PairSet;
use GraphQL\Utils\TypeInfo;
use GraphQL\Validator\ValidationContext;
use SplObjectStorage;
use function array_keys;
use function array_map;
use function array_merge;
@ -39,6 +40,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
* A memoization for when two fragments are compared "between" each other for
* conflicts. Two fragments may be compared many times, so memoizing this can
* dramatically improve the performance of this validator.
*
* @var PairSet
*/
private $comparedFragmentPairs;
@ -48,14 +50,14 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
* selection set. Selection sets may be asked for this information multiple
* times, so this improves the performance of this validator.
*
* @var \SplObjectStorage
* @var SplObjectStorage
*/
private $cachedFieldsAndFragmentNames;
public function getVisitor(ValidationContext $context)
{
$this->comparedFragmentPairs = new PairSet();
$this->cachedFieldsAndFragmentNames = new \SplObjectStorage();
$this->cachedFieldsAndFragmentNames = new SplObjectStorage();
return [
NodeKind::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) {
@ -83,6 +85,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
* GraphQL Document.
*
* @param CompositeType $parentType
*
* @return mixed[]
*/
private function findConflictsWithinSelectionSet(
@ -145,7 +148,8 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
* referenced via fragment spreads.
*
* @param CompositeType $parentType
* @return mixed[]|\SplObjectStorage
*
* @return mixed[]|SplObjectStorage
*/
private function getFieldsAndFragmentNames(
ValidationContext $context,
@ -224,7 +228,6 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
*
* J) Also, if two fragments are referenced in both selection sets, then a
* comparison is made "between" the two fragments.
*
*/
/**
@ -333,6 +336,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
* @param string $responseName
* @param mixed[] $field1
* @param mixed[] $field2
*
* @return mixed[]|null
*/
private function findConflict(
@ -503,6 +507,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
* @param bool $areMutuallyExclusive
* @param CompositeType $parentType1
* @param CompositeType $parentType2
*
* @return mixed[][]
*/
private function findConflictsBetweenSubSelectionSets(
@ -704,7 +709,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
* Given a reference to a fragment, return the represented collection of fields
* as well as a list of nested fragment names referenced via fragment spreads.
*
* @return mixed[]|\SplObjectStorage
* @return mixed[]|SplObjectStorage
*/
private function getReferencedFieldsAndFragmentNames(
ValidationContext $context,
@ -818,6 +823,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
*
* @param mixed[][] $conflicts
* @param string $responseName
*
* @return mixed[]|null
*/
private function subfieldConflicts(
@ -834,7 +840,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
[
$responseName,
array_map(
function ($conflict) {
static function ($conflict) {
return $conflict[0];
},
$conflicts
@ -842,14 +848,14 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
],
array_reduce(
$conflicts,
function ($allFields, $conflict) {
static function ($allFields, $conflict) {
return array_merge($allFields, $conflict[1]);
},
[$ast1]
),
array_reduce(
$conflicts,
function ($allFields, $conflict) {
static function ($allFields, $conflict) {
return array_merge($allFields, $conflict[2]);
},
[$ast2]
@ -876,7 +882,7 @@ class OverlappingFieldsCanBeMerged extends ValidationRule
{
if (is_array($reason)) {
$tmp = array_map(
function ($tmp) {
static function ($tmp) {
[$responseName, $subReason] = $tmp;
$reasonMessage = self::reasonMessage($subReason);

View File

@ -19,7 +19,7 @@ class ProvidedNonNullArguments extends ValidationRule
{
return [
NodeKind::FIELD => [
'leave' => function (FieldNode $fieldNode) use ($context) {
'leave' => static function (FieldNode $fieldNode) use ($context) {
$fieldDef = $context->getFieldDef();
if (! $fieldDef) {
@ -45,7 +45,7 @@ class ProvidedNonNullArguments extends ValidationRule
},
],
NodeKind::DIRECTIVE => [
'leave' => function (DirectiveNode $directiveNode) use ($context) {
'leave' => static function (DirectiveNode $directiveNode) use ($context) {
$directiveDef = $context->getDirective();
if (! $directiveDef) {
return Visitor::skipNode();

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace GraphQL\Validator\Rules;
use ArrayObject;
use GraphQL\Error\Error;
use GraphQL\Executor\Values;
use GraphQL\Language\AST\FieldNode;
@ -31,10 +32,10 @@ class QueryComplexity extends QuerySecurityRule
/** @var mixed[]|null */
private $rawVariableValues = [];
/** @var \ArrayObject */
/** @var ArrayObject */
private $variableDefs;
/** @var \ArrayObject */
/** @var ArrayObject */
private $fieldNodeAndDefs;
/** @var ValidationContext */
@ -49,8 +50,8 @@ class QueryComplexity extends QuerySecurityRule
{
$this->context = $context;
$this->variableDefs = new \ArrayObject();
$this->fieldNodeAndDefs = new \ArrayObject();
$this->variableDefs = new ArrayObject();
$this->fieldNodeAndDefs = new ArrayObject();
$complexity = 0;
return $this->invokeIfNeeded(
@ -196,7 +197,7 @@ class QueryComplexity extends QuerySecurityRule
throw new Error(implode(
"\n\n",
array_map(
function ($error) {
static function ($error) {
return $error->getMessage();
},
$variableValuesResult['errors']
@ -251,7 +252,7 @@ class QueryComplexity extends QuerySecurityRule
throw new Error(implode(
"\n\n",
array_map(
function ($error) {
static function ($error) {
return $error->getMessage();
},
$variableValuesResult['errors']

View File

@ -4,16 +4,18 @@ declare(strict_types=1);
namespace GraphQL\Validator\Rules;
use Closure;
use ArrayObject;
use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\NodeKind;
use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Introspection;
use GraphQL\Utils\TypeInfo;
use GraphQL\Validator\ValidationContext;
use InvalidArgumentException;
use function class_alias;
use function method_exists;
use function sprintf;
@ -34,7 +36,7 @@ abstract class QuerySecurityRule extends ValidationRule
protected function checkIfGreaterOrEqualToZero($name, $value)
{
if ($value < 0) {
throw new \InvalidArgumentException(sprintf('$%s argument must be greater or equal to 0.', $name));
throw new InvalidArgumentException(sprintf('$%s argument must be greater or equal to 0.', $name));
}
}
@ -55,8 +57,9 @@ abstract class QuerySecurityRule extends ValidationRule
}
/**
* @param Closure[] $validators
* @return Closure[]
* @param callable[] $validators
*
* @return callable[]
*/
protected function invokeIfNeeded(ValidationContext $context, array $validators)
{
@ -98,17 +101,17 @@ abstract class QuerySecurityRule extends ValidationRule
*
* @param Type|null $parentType
*
* @return \ArrayObject
* @return ArrayObject
*/
protected function collectFieldASTsAndDefs(
ValidationContext $context,
$parentType,
SelectionSetNode $selectionSet,
?\ArrayObject $visitedFragmentNames = null,
?\ArrayObject $astAndDefs = null
?ArrayObject $visitedFragmentNames = null,
?ArrayObject $astAndDefs = null
) {
$_visitedFragmentNames = $visitedFragmentNames ?: new \ArrayObject();
$_astAndDefs = $astAndDefs ?: new \ArrayObject();
$_visitedFragmentNames = $visitedFragmentNames ?: new ArrayObject();
$_astAndDefs = $astAndDefs ?: new ArrayObject();
foreach ($selectionSet->selections as $selection) {
switch ($selection->kind) {
@ -134,7 +137,7 @@ abstract class QuerySecurityRule extends ValidationRule
}
$responseName = $this->getFieldName($selection);
if (! isset($_astAndDefs[$responseName])) {
$_astAndDefs[$responseName] = new \ArrayObject();
$_astAndDefs[$responseName] = new ArrayObject();
}
// create field context
$_astAndDefs[$responseName][] = [$selection, $fieldDef];

View File

@ -16,7 +16,7 @@ class ScalarLeafs extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::FIELD => function (FieldNode $node) use ($context) {
NodeKind::FIELD => static function (FieldNode $node) use ($context) {
$type = $context->getType();
if (! $type) {
return;

View File

@ -15,7 +15,7 @@ class UniqueDirectivesPerLocation extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
'enter' => function (Node $node) use ($context) {
'enter' => static function (Node $node) use ($context) {
if (! isset($node->directives)) {
return;
}

View File

@ -22,7 +22,7 @@ class UniqueFragmentNames extends ValidationRule
$this->knownFragmentNames = [];
return [
NodeKind::OPERATION_DEFINITION => function () {
NodeKind::OPERATION_DEFINITION => static function () {
return Visitor::skipNode();
},
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {

View File

@ -38,7 +38,7 @@ class UniqueOperationNames extends ValidationRule
return Visitor::skipNode();
},
NodeKind::FRAGMENT_DEFINITION => function () {
NodeKind::FRAGMENT_DEFINITION => static function () {
return Visitor::skipNode();
},
];

View File

@ -6,7 +6,6 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Validator\ValidationContext;
use function class_alias;
use function get_class;
abstract class ValidationRule
{
@ -15,7 +14,7 @@ abstract class ValidationRule
public function getName()
{
return $this->name ?: get_class($this);
return $this->name ?: static::class;
}
public function __invoke(ValidationContext $context)
@ -27,6 +26,7 @@ abstract class ValidationRule
* Returns structure suitable for GraphQL\Language\Visitor
*
* @see \GraphQL\Language\Visitor
*
* @return mixed[]
*/
abstract public function getVisitor(ValidationContext $context);

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace GraphQL\Validator\Rules;
use Exception;
use GraphQL\Error\Error;
use GraphQL\Language\AST\BooleanValueNode;
use GraphQL\Language\AST\EnumValueNode;
@ -27,6 +28,7 @@ use GraphQL\Type\Definition\ScalarType;
use GraphQL\Type\Definition\Type;
use GraphQL\Utils\Utils;
use GraphQL\Validator\ValidationContext;
use Throwable;
use function array_combine;
use function array_keys;
use function array_map;
@ -45,7 +47,7 @@ class ValuesOfCorrectType extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::NULL => function (NullValueNode $node) use ($context) {
NodeKind::NULL => static function (NullValueNode $node) use ($context) {
$type = $context->getInputType();
if (! ($type instanceof NonNull)) {
return;
@ -82,7 +84,7 @@ class ValuesOfCorrectType extends ValidationRule
$nodeFields = iterator_to_array($node->fields);
$fieldNodeMap = array_combine(
array_map(
function ($field) {
static function ($field) {
return $field->name->value;
},
$nodeFields
@ -103,7 +105,7 @@ class ValuesOfCorrectType extends ValidationRule
);
}
},
NodeKind::OBJECT_FIELD => function (ObjectFieldNode $node) use ($context) {
NodeKind::OBJECT_FIELD => static function (ObjectFieldNode $node) use ($context) {
$parentType = Type::getNamedType($context->getParentInputType());
$fieldType = $context->getInputType();
if ($fieldType || ! ($parentType instanceof InputObjectType)) {
@ -193,7 +195,7 @@ class ValuesOfCorrectType extends ValidationRule
// may throw to indicate failure.
try {
$type->parseLiteral($node);
} catch (\Exception $error) {
} catch (Exception $error) {
// Ensure a reference to the original error is maintained.
$context->reportError(
new Error(
@ -209,7 +211,7 @@ class ValuesOfCorrectType extends ValidationRule
$error
)
);
} catch (\Throwable $error) {
} catch (Throwable $error) {
// Ensure a reference to the original error is maintained.
$context->reportError(
new Error(
@ -234,7 +236,7 @@ class ValuesOfCorrectType extends ValidationRule
$suggestions = Utils::suggestionList(
Printer::doPrint($node),
array_map(
function (EnumValueDefinition $value) {
static function (EnumValueDefinition $value) {
return $value->name;
},
$type->getValues()

View File

@ -18,7 +18,7 @@ class VariablesAreInputTypes extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $node) use ($context) {
NodeKind::VARIABLE_DEFINITION => static function (VariableDefinitionNode $node) use ($context) {
$type = TypeInfo::typeFromAST($context->getSchema(), $node->type);
// If the variable type is not an input type, return an error.

View File

@ -25,7 +25,7 @@ class VariablesDefaultValueAllowed extends ValidationRule
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $node) use ($context) {
NodeKind::VARIABLE_DEFINITION => static function (VariableDefinitionNode $node) use ($context) {
$name = $node->variable->name->value;
$defaultValue = $node->defaultValue;
$type = $context->getInputType();
@ -44,10 +44,10 @@ class VariablesDefaultValueAllowed extends ValidationRule
return Visitor::skipNode();
},
NodeKind::SELECTION_SET => function (SelectionSetNode $node) {
NodeKind::SELECTION_SET => static function (SelectionSetNode $node) {
return Visitor::skipNode();
},
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) {
NodeKind::FRAGMENT_DEFINITION => static function (FragmentDefinitionNode $node) {
return Visitor::skipNode();
},
];

View File

@ -71,7 +71,7 @@ class VariablesInAllowedPosition extends ValidationRule
private function effectiveType($varType, $varDef)
{
return (! $varDef->defaultValue || $varType instanceof NonNull) ? $varType : new NonNull($varType);
return ! $varDef->defaultValue || $varType instanceof NonNull ? $varType : new NonNull($varType);
}
/**

View File

@ -128,10 +128,10 @@ class ValidationContext
Visitor::visitWithTypeInfo(
$typeInfo,
[
NodeKind::VARIABLE_DEFINITION => function () {
NodeKind::VARIABLE_DEFINITION => static function () {
return false;
},
NodeKind::VARIABLE => function (VariableNode $variable) use (
NodeKind::VARIABLE => static function (VariableNode $variable) use (
&$newUsages,
$typeInfo
) {
@ -214,6 +214,7 @@ class ValidationContext
/**
* @param string $name
*
* @return FragmentDefinitionNode|null
*/
public function getFragment($name)