Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
54.55% |
12 / 22 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
Less_Tree_VariableCall | |
54.55% |
12 / 22 |
|
66.67% |
2 / 3 |
32.41 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
accept | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
compile | |
44.44% |
8 / 18 |
|
0.00% |
0 / 1 |
36.69 |
1 | <?php |
2 | /** |
3 | * @private |
4 | * @see less-3.13.1.js#VariableCall |
5 | * @todo missing allowRoot implementation https://github.com/less/less.js/commit/b67403d3 |
6 | */ |
7 | class Less_Tree_VariableCall extends Less_Tree { |
8 | |
9 | public $variable; |
10 | public $type = "VariableCall"; |
11 | /** |
12 | * @var int |
13 | */ |
14 | private $index; |
15 | /** |
16 | * @var array |
17 | */ |
18 | private $currentFileInfo; |
19 | |
20 | /** |
21 | * @param string $variable |
22 | */ |
23 | public function __construct( $variable, $index, $currentFileInfo ) { |
24 | $this->variable = $variable; |
25 | $this->index = $index; |
26 | $this->currentFileInfo = $currentFileInfo; |
27 | } |
28 | |
29 | public function accept( $visitor ) { |
30 | } |
31 | |
32 | public function compile( $env ) { |
33 | $detachedRuleset = ( new Less_Tree_Variable( $this->variable, $this->index, $this->currentFileInfo ) ) |
34 | ->compile( $env ); |
35 | |
36 | if ( !( $detachedRuleset instanceof Less_Tree_DetachedRuleset ) || !$detachedRuleset->ruleset ) { |
37 | // order differs from upstream to simplify the code |
38 | if ( is_array( $detachedRuleset ) ) { |
39 | $rules = new Less_Tree_Ruleset( null, $detachedRuleset ); |
40 | } elseif ( |
41 | ( $detachedRuleset instanceof Less_Tree_Ruleset |
42 | || $detachedRuleset instanceof Less_Tree_AtRule |
43 | || $detachedRuleset instanceof Less_Tree_Media |
44 | || $detachedRuleset instanceof Less_Tree_Mixin_Definition |
45 | ) && $detachedRuleset->rules |
46 | ) { |
47 | // @todo - note looks like dead code, do we need it ? |
48 | $rules = $detachedRuleset; |
49 | } elseif ( $detachedRuleset instanceof Less_Tree && is_array( $detachedRuleset->value ) ) { |
50 | // @phan-suppress-next-line PhanTypeMismatchArgument False positive |
51 | $rules = new Less_Tree_Ruleset( null, $detachedRuleset->value ); |
52 | } else { |
53 | throw new Less_Exception_Compiler( 'Could not evaluate variable call ' . $this->variable ); |
54 | } |
55 | $detachedRuleset = new Less_Tree_DetachedRuleset( $rules ); |
56 | } |
57 | if ( $detachedRuleset->ruleset ) { |
58 | return $detachedRuleset->callEval( $env ); |
59 | } |
60 | throw new Less_Exception_Compiler( 'Could not evaluate variable call ' . $this->variable ); |
61 | } |
62 | } |