Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.78% covered (warning)
83.78%
31 / 37
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Less_Tree_Property
83.78% covered (warning)
83.78%
31 / 37
50.00% covered (danger)
50.00%
1 / 2
9.35
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 compile
82.35% covered (warning)
82.35%
28 / 34
0.00% covered (danger)
0.00%
0 / 1
8.35
1<?php
2/**
3 * @private
4 * @see less-3.13.1.js#tree.Property
5 */
6class Less_Tree_Property extends Less_Tree {
7
8    public $name;
9    public $index;
10    public $currentFileInfo;
11    public $evaluating = false;
12
13    /**
14     * @param string $name
15     */
16    public function __construct( $name, $index = null, $currentFileInfo = null ) {
17        $this->name = $name;
18        $this->index = $index;
19        $this->currentFileInfo = $currentFileInfo;
20    }
21
22    public function compile( $env ) {
23        $name = $this->name;
24
25        if ( $this->evaluating ) {
26            throw new Less_Exception_Compiler( "Recursive property reference for " . $name, null,
27                $this->index, $this->currentFileInfo );
28        }
29
30        $property = null;
31        $this->evaluating = true;
32        /** @var Less_Tree_Ruleset $frame */
33        foreach ( $env->frames as $frame ) {
34            $vArr = $frame->property( $name );
35            if ( $vArr ) {
36                $size = count( $vArr );
37                for ( $i = 0; $i < $size; $i++ ) {
38                    $v = $vArr[$i];
39                    $vArr[$i] = new Less_Tree_Declaration(
40                        $v->name,
41                        $v->value,
42                        $v->important,
43                        $v->merge,
44                        $v->index,
45                        $v->currentFileInfo,
46                        $v->inline,
47                        $v->variable
48                    );
49                }
50                Less_Visitor_toCSS::_mergeRules( $vArr );
51                $v = $vArr[ count( $vArr ) - 1 ];
52                if ( isset( $v->important ) && $v->important ) {
53                    $importantScopeLength = count( $env->importantScope );
54                    $env->importantScope[ $importantScopeLength - 1 ]['important'] = $v->important;
55                }
56                $property = $v->value->compile( $env );
57                break;
58            }
59        }
60
61        if ( $property ) {
62            $this->evaluating = false;
63            return $property;
64        } else {
65            throw new Less_Exception_Compiler( "property '" . $name . "' is undefined in file " .
66                $this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo );
67        }
68    }
69
70}