Conditions | 6 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | public function enterNode(NodeInterface $node): ?NodeInterface |
||
25 | { |
||
26 | if ($node instanceof SelectionSetNode || $node instanceof FragmentDefinitionNode) { |
||
27 | return null; |
||
28 | } |
||
29 | |||
30 | if ($node instanceof VariableDefinitionNode) { |
||
31 | $variable = $node->getVariable(); |
||
32 | $variableName = $variable->getNameValue(); |
||
33 | $defaultValue = $node->getDefaultValue(); |
||
34 | $type = $this->validationContext->getInputType(); |
||
35 | |||
36 | if (null !== $defaultValue && $type instanceof NonNullType) { |
||
37 | $this->validationContext->reportError( |
||
38 | new ValidationException( |
||
39 | variableDefaultValueNotAllowedMessage($variableName, $type, $type->getOfType()), |
||
|
|||
40 | [$defaultValue] |
||
41 | ) |
||
42 | ); |
||
43 | } |
||
44 | |||
45 | return null; // do not traverse further. |
||
46 | } |
||
47 | |||
48 | return $node; |
||
49 | } |
||
51 |