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\DocBlock; |
16
|
|
|
use phpDocumentor\Reflection\Fqsen; |
17
|
|
|
use phpDocumentor\Reflection\Element; |
18
|
|
|
use phpDocumentor\Reflection\Location; |
19
|
|
|
use phpDocumentor\Reflection\Php\Visibility; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Descriptor representing a Method in a Class, Interface or Trait. |
23
|
|
|
*/ |
24
|
|
|
final class Method implements Element |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var DocBlock|null documentation of this method. |
28
|
|
|
*/ |
29
|
|
|
private $docBlock = null; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var Fqsen Full Qualified Structural Element Name |
33
|
|
|
*/ |
34
|
|
|
private $fqsen; |
35
|
|
|
|
36
|
|
|
/** @var bool $abstract */ |
37
|
|
|
private $abstract = false; |
38
|
|
|
|
39
|
|
|
/** @var bool $final */ |
40
|
|
|
private $final = false; |
41
|
|
|
|
42
|
|
|
/** @var bool $static */ |
43
|
|
|
private $static = false; |
44
|
|
|
|
45
|
|
|
/** @var Visibility visibility of this method */ |
46
|
|
|
private $visibility = null; |
47
|
|
|
|
48
|
|
|
/** @var Argument[] */ |
49
|
|
|
private $arguments = array(); |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var Location |
53
|
|
|
*/ |
54
|
|
|
private $location; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Initializes the all properties. |
58
|
|
|
* |
59
|
|
|
* @param Fqsen $fqsen |
60
|
7 |
|
* @param Visibility|null $visibility when null is provided a default 'public' is set. |
61
|
|
|
* @param DocBlock|null $docBlock |
62
|
|
|
* @param bool $abstract |
63
|
|
|
* @param bool $static |
64
|
|
|
* @param bool $final |
65
|
|
|
* @param Location|null $location |
66
|
|
|
*/ |
67
|
|
|
public function __construct( |
68
|
7 |
|
Fqsen $fqsen, |
69
|
7 |
|
Visibility $visibility = null, |
70
|
7 |
|
DocBlock $docBlock = null, |
71
|
|
|
$abstract = false, |
72
|
7 |
|
$static = false, |
73
|
2 |
|
$final = false, |
74
|
2 |
|
Location $location = null |
75
|
|
|
) { |
76
|
7 |
|
$this->fqsen = $fqsen; |
77
|
7 |
|
$this->visibility = $visibility; |
78
|
7 |
|
$this->docBlock = $docBlock; |
79
|
7 |
|
|
80
|
|
|
if ($this->visibility === null) { |
81
|
|
|
$this->visibility = new Visibility('public'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if ($location === null) { |
85
|
|
|
$location = new Location(-1); |
86
|
1 |
|
} |
87
|
|
|
|
88
|
1 |
|
$this->abstract = $abstract; |
89
|
|
|
$this->static = $static; |
90
|
|
|
$this->final = $final; |
91
|
|
|
$this->location = $location; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns true when this method is abstract. Otherwise returns false. |
96
|
1 |
|
* |
97
|
|
|
* @return bool |
98
|
1 |
|
*/ |
99
|
|
|
public function isAbstract() |
100
|
|
|
{ |
101
|
|
|
return $this->abstract; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Returns true when this method is final. Otherwise returns false. |
106
|
1 |
|
* |
107
|
|
|
* @return bool |
108
|
1 |
|
*/ |
109
|
|
|
public function isFinal() |
110
|
|
|
{ |
111
|
|
|
return $this->final; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Returns true when this method is static. Otherwise returns false. |
116
|
2 |
|
* |
117
|
|
|
* @return bool |
118
|
2 |
|
*/ |
119
|
|
|
public function isStatic() |
120
|
|
|
{ |
121
|
|
|
return $this->static; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Returns the Visibility of this method. |
126
|
1 |
|
* |
127
|
|
|
* @return Visibility |
128
|
1 |
|
*/ |
129
|
|
|
public function getVisibility() |
130
|
|
|
{ |
131
|
|
|
return $this->visibility; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Returns the arguments of this method. |
136
|
|
|
* |
137
|
|
|
* @return Argument[] |
138
|
1 |
|
*/ |
139
|
|
|
public function getArguments() |
140
|
1 |
|
{ |
141
|
1 |
|
return $this->arguments; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Add new argument to this method. |
147
|
|
|
* |
148
|
1 |
|
* @param Argument $argument |
149
|
|
|
* @return void |
150
|
1 |
|
*/ |
151
|
|
|
public function addArgument(Argument $argument) |
152
|
|
|
{ |
153
|
|
|
$this->arguments[] = $argument; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Returns the Fqsen of the element. |
158
|
1 |
|
* |
159
|
|
|
* @return Fqsen |
160
|
1 |
|
*/ |
161
|
|
|
public function getFqsen() |
162
|
|
|
{ |
163
|
|
|
return $this->fqsen; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Returns the name of the element. |
168
|
1 |
|
* |
169
|
|
|
* @return string |
170
|
1 |
|
*/ |
171
|
|
|
public function getName() |
172
|
|
|
{ |
173
|
|
|
return $this->fqsen->getName(); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Returns the DocBlock of this method if available. |
178
|
|
|
* |
179
|
|
|
* @returns null|DocBlock |
180
|
|
|
*/ |
181
|
|
|
public function getDocBlock() |
182
|
|
|
{ |
183
|
|
|
return $this->docBlock; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return Location |
188
|
|
|
*/ |
189
|
|
|
public function getLocation() |
190
|
|
|
{ |
191
|
|
|
return $this->location; |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|