This commit is contained in:
Your Name
2021-07-26 19:46:18 +02:00
parent e7a49138bb
commit aae17f10a6
818 changed files with 70695 additions and 16408 deletions
@@ -22,13 +22,15 @@ class NoUnusedVariables extends ValidationRule
return [
NodeKind::OPERATION_DEFINITION => [
'enter' => function () {
'enter' => function () : void {
$this->variableDefs = [];
},
'leave' => function (OperationDefinitionNode $operation) use ($context) {
'leave' => function (OperationDefinitionNode $operation) use ($context) : void {
$variableNameUsed = [];
$usages = $context->getRecursiveVariableUsages($operation);
$opName = $operation->name ? $operation->name->value : null;
$opName = $operation->name !== null
? $operation->name->value
: null;
foreach ($usages as $usage) {
$node = $usage['node'];
@@ -38,7 +40,7 @@ class NoUnusedVariables extends ValidationRule
foreach ($this->variableDefs as $variableDef) {
$variableName = $variableDef->variable->name->value;
if (! empty($variableNameUsed[$variableName])) {
if ($variableNameUsed[$variableName] ?? false) {
continue;
}
@@ -49,7 +51,7 @@ class NoUnusedVariables extends ValidationRule
}
},
],
NodeKind::VARIABLE_DEFINITION => function ($def) {
NodeKind::VARIABLE_DEFINITION => function ($def) : void {
$this->variableDefs[] = $def;
},
];