1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* This file is part of phpDocumentor. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @copyright 2010-2018 Mike van Riel<[email protected]> |
11
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
12
|
|
|
* @link http://phpdoc.org |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace phpDocumentor\Reflection\Php; |
16
|
|
|
|
17
|
|
|
use phpDocumentor\Reflection\DocBlock; |
18
|
|
|
use phpDocumentor\Reflection\Element; |
19
|
|
|
use phpDocumentor\Reflection\Fqsen; |
20
|
|
|
use phpDocumentor\Reflection\Location; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Descriptor representing an Interface. |
24
|
|
|
*/ |
25
|
|
|
// @codingStandardsIgnoreStart |
26
|
|
|
final class Interface_ implements Element |
27
|
|
|
// @codingStandardsIgnoreEnd |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var Fqsen Full Qualified Structural Element Name |
31
|
|
|
*/ |
32
|
|
|
private $fqsen; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var DocBlock|null |
36
|
|
|
*/ |
37
|
|
|
private $docBlock; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var Constant[] |
41
|
|
|
*/ |
42
|
|
|
private $constants = []; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var Method[] |
46
|
|
|
*/ |
47
|
|
|
private $methods = []; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var Fqsen[] |
51
|
|
|
*/ |
52
|
|
|
private $parents = []; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var Location |
56
|
|
|
*/ |
57
|
|
|
private $location; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Initializes the object. |
61
|
|
|
* |
62
|
|
|
* @param Fqsen[] $parents |
63
|
|
|
*/ |
64
|
2 |
|
public function __construct( |
65
|
|
|
Fqsen $fqsen, |
66
|
|
|
array $parents = [], |
67
|
|
|
?DocBlock $docBlock = null, |
68
|
|
|
?Location $location = null |
69
|
|
|
) { |
70
|
2 |
|
if ($location === null) { |
71
|
2 |
|
$location = new Location(-1); |
72
|
|
|
} |
73
|
|
|
|
74
|
2 |
|
$this->fqsen = $fqsen; |
75
|
2 |
|
$this->docBlock = $docBlock; |
76
|
2 |
|
$this->parents = $parents; |
77
|
2 |
|
$this->location = $location; |
78
|
2 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Returns the constants of this interface. |
82
|
|
|
* |
83
|
|
|
* @return Constant[] |
84
|
|
|
*/ |
85
|
1 |
|
public function getConstants(): array |
86
|
|
|
{ |
87
|
1 |
|
return $this->constants; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Add constant to this interface. |
92
|
|
|
*/ |
93
|
1 |
|
public function addConstant(Constant $constant): void |
94
|
|
|
{ |
95
|
1 |
|
$this->constants[(string) $constant->getFqsen()] = $constant; |
96
|
1 |
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Returns the methods in this interface. |
100
|
|
|
* |
101
|
|
|
* @return Method[] |
102
|
|
|
*/ |
103
|
1 |
|
public function getMethods(): array |
104
|
|
|
{ |
105
|
1 |
|
return $this->methods; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Add method to this interface. |
110
|
|
|
*/ |
111
|
1 |
|
public function addMethod(Method $method): void |
112
|
|
|
{ |
113
|
1 |
|
$this->methods[(string) $method->getFqsen()] = $method; |
114
|
1 |
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Returns the Fqsen of the element. |
118
|
|
|
*/ |
119
|
1 |
|
public function getFqsen(): Fqsen |
120
|
|
|
{ |
121
|
1 |
|
return $this->fqsen; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Returns the name of the element. |
126
|
|
|
*/ |
127
|
|
|
public function getName(): string |
128
|
|
|
{ |
129
|
|
|
return $this->fqsen->getName(); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Returns the DocBlock of this interface if available. |
134
|
|
|
*/ |
135
|
1 |
|
public function getDocBlock(): ?DocBlock |
136
|
|
|
{ |
137
|
1 |
|
return $this->docBlock; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Returns the Fqsen of the interfaces this interface is extending. |
142
|
|
|
* |
143
|
|
|
* @return Fqsen[] |
144
|
|
|
*/ |
145
|
|
|
public function getParents(): array |
146
|
|
|
{ |
147
|
|
|
return $this->parents; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function getLocation(): Location |
151
|
|
|
{ |
152
|
|
|
return $this->location; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|