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