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