Conditions | 4 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public function enterNode(NodeInterface $node): ?NodeInterface |
||
27 | { |
||
28 | if ($node instanceof OperationDefinitionNode) { |
||
29 | $this->knownVariableNames = []; |
||
30 | } |
||
31 | |||
32 | if ($node instanceof VariableDefinitionNode) { |
||
33 | $variable = $node->getVariable(); |
||
34 | $variableName = $variable->getNameValue(); |
||
35 | |||
36 | if (isset($this->knownVariableNames[$variableName])) { |
||
37 | $this->validationContext->reportError( |
||
38 | new ValidationException( |
||
39 | duplicateVariableMessage($variableName), |
||
40 | [$this->knownVariableNames[$variableName], $variable->getName()] |
||
41 | ) |
||
42 | ); |
||
43 | } else { |
||
44 | $this->knownVariableNames[$variableName] = $variable->getName(); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | return $node; |
||
49 | } |
||
51 |