1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Digia\GraphQL\Language\Node; |
4
|
|
|
|
5
|
|
|
use Digia\GraphQL\Language\Location; |
6
|
|
|
use Digia\GraphQL\Util\SerializationInterface; |
7
|
|
|
|
8
|
|
|
class DirectiveDefinitionNode extends AbstractNode implements DefinitionNodeInterface, NameAwareInterface |
9
|
|
|
{ |
10
|
|
|
use DescriptionTrait; |
11
|
|
|
use NameTrait; |
12
|
|
|
use InputArgumentsTrait; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var NameNode[] |
16
|
|
|
*/ |
17
|
|
|
protected $locations; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* DirectiveDefinitionNode constructor. |
21
|
|
|
* |
22
|
|
|
* @param StringValueNode|null $description |
23
|
|
|
* @param NameNode $name |
24
|
|
|
* @param ArgumentNode[] $arguments |
25
|
|
|
* @param NameNode[] $locations |
26
|
|
|
* @param Location|null $location |
27
|
|
|
*/ |
28
|
|
|
public function __construct( |
29
|
|
|
?StringValueNode $description, |
30
|
|
|
NameNode $name, |
31
|
|
|
array $arguments, |
32
|
|
|
array $locations, |
33
|
|
|
?Location $location |
34
|
|
|
) { |
35
|
|
|
parent::__construct(NodeKindEnum::DIRECTIVE_DEFINITION, $location); |
36
|
|
|
|
37
|
|
|
$this->description = $description; |
38
|
|
|
$this->name = $name; |
39
|
|
|
$this->arguments = $arguments; |
|
|
|
|
40
|
|
|
$this->locations = $locations; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return NameNode[] |
45
|
|
|
*/ |
46
|
|
|
public function getLocations(): array |
47
|
|
|
{ |
48
|
|
|
return $this->locations; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return array |
53
|
|
|
*/ |
54
|
|
|
public function getLocationsAsArray(): array |
55
|
|
|
{ |
56
|
|
|
return \array_map(function (SerializationInterface $node) { |
57
|
|
|
return $node->toArray(); |
58
|
|
|
}, $this->locations); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param NameNode[] $locations |
63
|
|
|
* @return $this |
64
|
|
|
*/ |
65
|
|
|
public function setLocations(array $locations) |
66
|
|
|
{ |
67
|
|
|
$this->locations = $locations; |
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @inheritdoc |
73
|
|
|
*/ |
74
|
|
|
public function toArray(): array |
75
|
|
|
{ |
76
|
|
|
return [ |
77
|
|
|
'kind' => $this->kind, |
78
|
|
|
'description' => $this->getDescriptionAsArray(), |
79
|
|
|
'name' => $this->getNameAsArray(), |
80
|
|
|
'arguments' => $this->getArgumentsAsArray(), |
81
|
|
|
'locations' => $this->getLocationsAsArray(), |
82
|
|
|
'loc' => $this->getLocationAsArray(), |
83
|
|
|
]; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..