|
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
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Descriptor representing a constant |
|
22
|
|
|
*/ |
|
23
|
|
|
final class Constant implements Element |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var Fqsen |
|
27
|
|
|
*/ |
|
28
|
|
|
private $fqsen; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var null|DocBlock |
|
32
|
|
|
*/ |
|
33
|
|
|
private $docBlock; |
|
34
|
|
|
|
|
35
|
|
|
/** @var null|string $value */ |
|
36
|
|
|
protected $value; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var Location |
|
40
|
|
|
*/ |
|
41
|
|
|
private $location; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
3 |
|
* Initializes the object. |
|
45
|
|
|
* |
|
46
|
3 |
|
* @param Fqsen $fqsen |
|
47
|
3 |
|
* @param DocBlock|null $docBlock |
|
48
|
3 |
|
* @param null|string $value |
|
49
|
3 |
|
* @param Location|null $location |
|
50
|
|
|
*/ |
|
51
|
|
|
public function __construct(Fqsen $fqsen, DocBlock $docBlock = null, $value = null, Location $location = null) |
|
52
|
|
|
{ |
|
53
|
|
|
$this->fqsen = $fqsen; |
|
54
|
|
|
$this->docBlock = $docBlock; |
|
55
|
|
|
$this->value = $value; |
|
56
|
1 |
|
|
|
57
|
|
|
if ($location === null) { |
|
58
|
1 |
|
$location = new Location(-1); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$this->location = $location; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Returns the value of this constant. |
|
66
|
1 |
|
* |
|
67
|
|
|
* @return null|string |
|
68
|
1 |
|
*/ |
|
69
|
|
|
public function getValue() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->value; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Returns the Fqsen of the element. |
|
76
|
1 |
|
* |
|
77
|
|
|
* @return Fqsen |
|
78
|
1 |
|
*/ |
|
79
|
|
|
public function getFqsen() |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->fqsen; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Returns the name of the element. |
|
86
|
1 |
|
* |
|
87
|
|
|
* @return string |
|
88
|
1 |
|
*/ |
|
89
|
|
|
public function getName() |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->fqsen->getName(); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Returns DocBlock of this constant if available. |
|
96
|
|
|
* |
|
97
|
|
|
* @return null|DocBlock |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getDocBlock() |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->docBlock; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @return Location |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getLocation() |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->location; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|