1 | <?php |
||
10 | class ReflectionClassUse implements \Reflector |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * The name of the trait. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name; |
||
19 | |||
20 | /** |
||
21 | * The conflict resolutions of the trait. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | private $conflictResolutions = array(); |
||
26 | |||
27 | /** |
||
28 | * The class where the use statement has been declared. |
||
29 | * |
||
30 | * @var \Wingu\OctopusCore\Reflection\ReflectionClass |
||
31 | */ |
||
32 | protected $declaringClass; |
||
33 | |||
34 | /** |
||
35 | * The tokens list of the parsed PHP code. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | private $tokens = array(); |
||
40 | |||
41 | /** |
||
42 | * The number of tokens found in the code. |
||
43 | * |
||
44 | * @var integer |
||
45 | */ |
||
46 | private $tokensCount = 0; |
||
47 | |||
48 | /** |
||
49 | * The current token position. |
||
50 | * |
||
51 | * @var integer |
||
52 | */ |
||
53 | private $tokenPos = 0; |
||
54 | |||
55 | /** |
||
56 | * Constructor. |
||
57 | * |
||
58 | * @param string $class The class name where the use statement is defined. |
||
59 | * @param string $name The name of the trait. |
||
60 | */ |
||
61 | 36 | public function __construct($class, $name) |
|
70 | |||
71 | /** |
||
72 | * Get the name of the trait. |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | 24 | public function getName() |
|
80 | |||
81 | /** |
||
82 | * Get the conflict resolutions. |
||
83 | * |
||
84 | * @return array |
||
85 | */ |
||
86 | 24 | public function getConflictResolutions() |
|
90 | |||
91 | /** |
||
92 | * Find the conflict resolutions of a trait. |
||
93 | * |
||
94 | * @throws \Wingu\OctopusCore\Reflection\Annotation\Exceptions\InvalidArgumentException If the trait is not found. |
||
95 | */ |
||
96 | 39 | protected function findConflictResolutions() |
|
117 | |||
118 | /** |
||
119 | * Extract the conflicts from the current use statement. |
||
120 | * |
||
121 | * @return array |
||
122 | */ |
||
123 | 39 | private function extractConflictsFromUseStatement() |
|
176 | |||
177 | /** |
||
178 | * Check if the found trait name is the one that we need to reflect. |
||
179 | * |
||
180 | * @param string $name The name of the trait found. |
||
181 | * @return boolean |
||
182 | */ |
||
183 | 36 | private function isSearchedTrait($name) |
|
197 | |||
198 | /** |
||
199 | * Return the next token that is not a whitespace or comment. |
||
200 | * |
||
201 | * @param boolean $includeWhiteSpace Flag if the whitespace should also be returned. |
||
202 | * @return mixed |
||
203 | */ |
||
204 | 39 | private function next($includeWhiteSpace = false) |
|
217 | |||
218 | /** |
||
219 | * Export the current use statement reflection. |
||
220 | * |
||
221 | * @param string $className The class name where the use statement is defined. |
||
222 | * @param string $name The name of the trait. |
||
223 | * @param boolean $return Flag if the export should be returned or not. |
||
224 | * @return string |
||
225 | */ |
||
226 | 9 | public static function export($className, $name, $return = false) |
|
238 | |||
239 | /** |
||
240 | * Return the string representation of the ReflectionConstant object. |
||
241 | * |
||
242 | * @return string |
||
243 | */ |
||
244 | 9 | public function __toString() |
|
253 | } |
||
254 |