1 | <?php |
||
8 | class Tree |
||
9 | { |
||
10 | /** @var array Collection of ignored DOM nodes */ |
||
11 | public static $ignoredNodes = array( |
||
12 | 'head', |
||
13 | 'meta', |
||
14 | 'script', |
||
15 | 'noscript', |
||
16 | 'link', |
||
17 | 'title', |
||
18 | 'br', |
||
19 | ); |
||
20 | |||
21 | /** |
||
22 | * Build destination code tree from source code. |
||
23 | * |
||
24 | * @param string $source Source code |
||
25 | * |
||
26 | * @return Node Less tree root node |
||
27 | */ |
||
28 | 2 | public function build($source) |
|
36 | |||
37 | /** |
||
38 | * Source code cleaner. |
||
39 | * |
||
40 | * @param string $source |
||
41 | * |
||
42 | * @return string Cleared source code |
||
43 | */ |
||
44 | 2 | protected function prepare($source) |
|
49 | |||
50 | /** |
||
51 | * Analyze source code and create destination code tree. |
||
52 | * |
||
53 | * @param string $source Source code |
||
54 | * |
||
55 | * @return Node Internal code tree |
||
56 | */ |
||
57 | 2 | protected function &analyze($source) |
|
68 | |||
69 | /** |
||
70 | * Perform source node analysis. |
||
71 | * |
||
72 | * @param \DOMNode $domNode |
||
73 | * @param Node $parent |
||
74 | * |
||
75 | * @return Node |
||
76 | */ |
||
77 | 2 | protected function &analyzeSourceNode(\DOMNode $domNode, Node $parent) |
|
130 | |||
131 | /** |
||
132 | * Get DOM node attribute value. |
||
133 | * |
||
134 | * @param \DOMNode $domNode |
||
135 | * @param string $attributeName |
||
136 | * |
||
137 | * @return null|string DOM node attribute value |
||
138 | */ |
||
139 | 2 | protected function getDOMAttributeValue(\DOMNode $domNode, $attributeName) |
|
155 | |||
156 | /** |
||
157 | * Get current \DOMNode LESS selector. |
||
158 | * |
||
159 | * @param \DOMNode $child |
||
160 | * @param string $tag |
||
161 | * @param array $classes |
||
162 | * |
||
163 | * @return string LESS selector |
||
164 | */ |
||
165 | 2 | protected function getSelector(\DOMNode $child, $tag, array &$classes) |
|
178 | |||
179 | /** |
||
180 | * Optimize by grouping tag name LESS nodes. |
||
181 | * |
||
182 | * @param Node [string] $tagNodes |
||
183 | * @param Node $parent |
||
184 | */ |
||
185 | 2 | protected function optimizeGroupTags($tagNodes, Node $parent) |
|
225 | |||
226 | /** |
||
227 | * Render LESS tree. This function is recursive. |
||
228 | * |
||
229 | * @param Node $node Current LESS tree node |
||
230 | * @param string $output Final LESS code string |
||
231 | * @param int $level Current recursion level |
||
232 | * |
||
233 | * @return string LESS code |
||
234 | */ |
||
235 | 2 | public function output(Node $node, $output = '', $level = 0) |
|
249 | |||
250 | /** |
||
251 | * Get spaces for LESS tree level. |
||
252 | * |
||
253 | * @param int $level LESS tree depth |
||
254 | * |
||
255 | * @return string Spaces for current LESS tree depth |
||
256 | */ |
||
257 | 2 | protected function spaces($level = 0) |
|
261 | } |
||
262 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.