1 | <?php |
||
23 | final class ClassConstantIterator implements \Iterator |
||
24 | { |
||
25 | /** |
||
26 | * @var ClassConst |
||
27 | */ |
||
28 | private $classConstants; |
||
29 | |||
30 | /** @var int index of the current ClassConst to use */ |
||
31 | private $index = 0; |
||
32 | |||
33 | /** |
||
34 | * Initializes the class with source data. |
||
35 | * |
||
36 | * @param ClassConst $classConst |
||
37 | */ |
||
38 | 1 | public function __construct(ClassConst $classConst) |
|
42 | |||
43 | /** |
||
44 | * Gets line the node started in. |
||
45 | * |
||
46 | * @return int Line |
||
47 | */ |
||
48 | 1 | public function getLine() |
|
52 | |||
53 | /** |
||
54 | * Returns the name of the current constant. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | 1 | public function getName() |
|
62 | |||
63 | /** |
||
64 | * Returns the fqsen of the current constant. |
||
65 | * |
||
66 | * @return Fqsen |
||
67 | */ |
||
68 | 1 | public function getFqsen() |
|
72 | |||
73 | /** |
||
74 | * Gets the doc comment of the node. |
||
75 | * |
||
76 | * The doc comment has to be the last comment associated with the node. |
||
77 | * |
||
78 | * @return null|Doc Doc comment object or null |
||
79 | */ |
||
80 | 2 | public function getDocComment() |
|
81 | { |
||
82 | 2 | $docComment = $this->classConstants->consts[$this->index]->getDocComment(); |
|
83 | 2 | if ($docComment === null) { |
|
84 | 1 | $docComment = $this->classConstants->getDocComment(); |
|
85 | } |
||
86 | |||
87 | 2 | return $docComment; |
|
88 | } |
||
89 | |||
90 | public function getValue() |
||
94 | |||
95 | /** |
||
96 | * (PHP 5 >= 5.0.0)<br/> |
||
97 | * Return the current element |
||
98 | * @link http://php.net/manual/en/iterator.current.php |
||
99 | * @return mixed Can return any type. |
||
100 | */ |
||
101 | 1 | public function current() |
|
105 | |||
106 | /** |
||
107 | * (PHP 5 >= 5.0.0)<br/> |
||
108 | * Move forward to next element |
||
109 | * @link http://php.net/manual/en/iterator.next.php |
||
110 | * @return void Any returned value is ignored. |
||
111 | */ |
||
112 | 2 | public function next() |
|
116 | |||
117 | /** |
||
118 | * (PHP 5 >= 5.0.0)<br/> |
||
119 | * Return the key of the current element |
||
120 | * @link http://php.net/manual/en/iterator.key.php |
||
121 | * @return mixed scalar on success, or null on failure. |
||
122 | */ |
||
123 | 1 | public function key() |
|
127 | |||
128 | /** |
||
129 | * (PHP 5 >= 5.0.0)<br/> |
||
130 | * Checks if current position is valid |
||
131 | * @link http://php.net/manual/en/iterator.valid.php |
||
132 | * @return boolean The return value will be casted to boolean and then evaluated. |
||
133 | * Returns true on success or false on failure. |
||
134 | */ |
||
135 | 1 | public function valid() |
|
139 | |||
140 | /** |
||
141 | * (PHP 5 >= 5.0.0)<br/> |
||
142 | * Rewind the Iterator to the first element |
||
143 | * @link http://php.net/manual/en/iterator.rewind.php |
||
144 | * @return void Any returned value is ignored. |
||
145 | */ |
||
146 | 1 | public function rewind() |
|
150 | } |
||
151 |