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
|
|
|
/** @var Constant[] $constants */ |
40
|
|
|
private $constants = []; |
41
|
|
|
|
42
|
|
|
/** @var Method[] $methods */ |
43
|
|
|
private $methods = []; |
44
|
|
|
|
45
|
|
|
/** @var Fqsen[] $parents */ |
46
|
|
|
private $parents = []; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var Location |
50
|
|
|
*/ |
51
|
|
|
private $location; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Initializes the object. |
55
|
|
|
* |
56
|
|
|
* @param Fqsen[] $parents |
57
|
|
|
*/ |
58
|
2 |
|
public function __construct( |
59
|
|
|
Fqsen $fqsen, |
60
|
|
|
array $parents = [], |
61
|
|
|
DocBlock $docBlock = null, |
62
|
|
|
Location $location = null |
63
|
|
|
) { |
64
|
2 |
|
if ($location === null) { |
65
|
2 |
|
$location = new Location(-1); |
66
|
|
|
} |
67
|
|
|
|
68
|
2 |
|
$this->fqsen = $fqsen; |
69
|
2 |
|
$this->docBlock = $docBlock; |
70
|
2 |
|
$this->parents = $parents; |
71
|
2 |
|
$this->location = $location; |
72
|
2 |
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Returns the constants of this interface. |
76
|
|
|
* |
77
|
|
|
* @return Constant[] |
78
|
|
|
*/ |
79
|
1 |
|
public function getConstants(): array |
80
|
|
|
{ |
81
|
1 |
|
return $this->constants; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Add constant to this interface. |
86
|
|
|
*/ |
87
|
1 |
|
public function addConstant(Constant $constant): void |
88
|
|
|
{ |
89
|
1 |
|
$this->constants[(string) $constant->getFqsen()] = $constant; |
90
|
1 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Returns the methods in this interface. |
94
|
|
|
* |
95
|
|
|
* @return Method[] |
96
|
|
|
*/ |
97
|
1 |
|
public function getMethods(): array |
98
|
|
|
{ |
99
|
1 |
|
return $this->methods; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Add method to this interface. |
104
|
|
|
*/ |
105
|
1 |
|
public function addMethod(Method $method): void |
106
|
|
|
{ |
107
|
1 |
|
$this->methods[(string) $method->getFqsen()] = $method; |
108
|
1 |
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Returns the Fqsen of the element. |
112
|
|
|
*/ |
113
|
1 |
|
public function getFqsen(): Fqsen |
114
|
|
|
{ |
115
|
1 |
|
return $this->fqsen; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Returns the name of the element. |
120
|
|
|
*/ |
121
|
|
|
public function getName(): string |
122
|
|
|
{ |
123
|
|
|
return $this->fqsen->getName(); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Returns the DocBlock of this interface if available. |
128
|
|
|
*/ |
129
|
1 |
|
public function getDocBlock(): ?DocBlock |
130
|
|
|
{ |
131
|
1 |
|
return $this->docBlock; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Returns the Fqsen of the interfaces this interface is extending. |
136
|
|
|
* |
137
|
|
|
* @return Fqsen[] |
138
|
|
|
*/ |
139
|
|
|
public function getParents(): array |
140
|
|
|
{ |
141
|
|
|
return $this->parents; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function getLocation(): Location |
145
|
|
|
{ |
146
|
|
|
return $this->location; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|