Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
96.30% |
26 / 27 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
Less_Tree_Extend | |
96.30% |
26 / 27 |
|
80.00% |
4 / 5 |
11 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
3 | |||
accept | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
compile | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
clone | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
findSelfSelectors | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
5.07 |
1 | <?php |
2 | /** |
3 | * @private |
4 | */ |
5 | class Less_Tree_Extend extends Less_Tree { |
6 | |
7 | public $selector; |
8 | public $option; |
9 | public $index; |
10 | public $selfSelectors = []; |
11 | public $allowBefore; |
12 | public $allowAfter; |
13 | public $firstExtendOnThisSelectorPath; |
14 | public $ruleset; |
15 | |
16 | public $object_id; |
17 | public $parent_ids = []; |
18 | |
19 | /** |
20 | * @param Less_Tree_Selector $selector |
21 | * @param string $option |
22 | * @param int $index |
23 | */ |
24 | public function __construct( $selector, $option, $index ) { |
25 | static $i = 0; |
26 | $this->selector = $selector; |
27 | $this->option = $option; |
28 | $this->index = $index; |
29 | |
30 | switch ( $option ) { |
31 | case "all": |
32 | $this->allowBefore = true; |
33 | $this->allowAfter = true; |
34 | break; |
35 | default: |
36 | $this->allowBefore = false; |
37 | $this->allowAfter = false; |
38 | break; |
39 | } |
40 | |
41 | // This must use a string (instead of int) so that array_merge() |
42 | // preserves keys on arrays that use IDs in their keys. |
43 | $this->object_id = 'id_' . $i++; |
44 | |
45 | $this->parent_ids = [ |
46 | $this->object_id => true |
47 | ]; |
48 | } |
49 | |
50 | public function accept( $visitor ) { |
51 | $this->selector = $visitor->visitObj( $this->selector ); |
52 | } |
53 | |
54 | public function compile( $env ) { |
55 | Less_Parser::$has_extends = true; |
56 | $this->selector = $this->selector->compile( $env ); |
57 | return $this; |
58 | // return new self( $this->selector->compile($env), $this->option, $this->index); |
59 | } |
60 | |
61 | public function clone() { |
62 | return new self( $this->selector, $this->option, $this->index ); |
63 | } |
64 | |
65 | public function findSelfSelectors( $selectors ) { |
66 | $selfElements = []; |
67 | |
68 | for ( $i = 0, $selectors_len = count( $selectors ); $i < $selectors_len; $i++ ) { |
69 | $selectorElements = $selectors[$i]->elements; |
70 | // duplicate the logic in genCSS function inside the selector node. |
71 | // future TODO - move both logics into the selector joiner visitor |
72 | if ( $i && $selectorElements && $selectorElements[0]->combinator === "" ) { |
73 | $selectorElements[0]->combinator = ' '; |
74 | } |
75 | $selfElements = array_merge( $selfElements, $selectors[$i]->elements ); |
76 | } |
77 | |
78 | $this->selfSelectors = [ new Less_Tree_Selector( $selfElements ) ]; |
79 | } |
80 | |
81 | } |