1 | <?php |
||
8 | class ReflectionConstant implements \Reflector |
||
9 | { |
||
10 | |||
11 | use ReflectionDocCommentTrait; |
||
12 | |||
13 | /** |
||
14 | * The name of the constant. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name; |
||
19 | |||
20 | /** |
||
21 | * The value of the constant. |
||
22 | * |
||
23 | * @var mixed |
||
24 | */ |
||
25 | protected $value; |
||
26 | |||
27 | /** |
||
28 | * The class where the constant has been declared. |
||
29 | * |
||
30 | * @var \Wingu\OctopusCore\Reflection\ReflectionClass |
||
31 | */ |
||
32 | protected $declaringClass; |
||
33 | |||
34 | /** |
||
35 | * Constructor. |
||
36 | * |
||
37 | * @param string $class The name of the class where the constant has been declared. |
||
38 | * @param string $name The name of the constant to reflect. |
||
39 | */ |
||
40 | 30 | public function __construct($class, $name) |
|
46 | |||
47 | /** |
||
48 | * Get a reflection of the class where the constant has been declared. |
||
49 | * |
||
50 | * @return \Wingu\OctopusCore\Reflection\ReflectionClass |
||
51 | */ |
||
52 | 12 | public function getDeclaringClass() |
|
56 | |||
57 | /** |
||
58 | * Get the value of the constant. |
||
59 | * |
||
60 | * @return mixed |
||
61 | */ |
||
62 | 3 | public function getValue() |
|
66 | |||
67 | /** |
||
68 | * Get the name of the constant. |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 15 | public function getName() |
|
76 | |||
77 | /** |
||
78 | * Export the current constant reflection. |
||
79 | * |
||
80 | * @param string $className The class name where the constant is defined. |
||
81 | * @param string $constantName The name of the constant. |
||
82 | * @param boolean $return Flag if the export should be returned or not. |
||
83 | * @return string |
||
84 | */ |
||
85 | 6 | public static function export($className, $constantName, $return = false) |
|
97 | |||
98 | /** |
||
99 | * Return the string representation of the ReflectionConstant object. |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | 6 | public function __toString() |
|
107 | |||
108 | /** |
||
109 | * Return the string containing the current constant comment or false if there's no comment. |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 9 | public function getDocComment() |
|
122 | |||
123 | /** |
||
124 | * Returns the doc comment from an existing filename or false if empty. |
||
125 | * |
||
126 | * @param string $fileName an existing filename |
||
127 | * @return string |
||
128 | */ |
||
129 | 6 | private function getDocCommentFromFile($fileName) |
|
156 | |||
157 | /** |
||
158 | * Returns the current constant declaration key in the list of given tokens. Returns 0 if not found. |
||
159 | * |
||
160 | * @param array $tokens the array of tokens (see http://www.php.net/manual/en/ref.tokenizer.php) |
||
161 | * @return int |
||
162 | */ |
||
163 | 6 | private function getCurrentConstantKeyFromClassTokens($tokens) |
|
185 | } |
||
186 |