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