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