Debian Codegraph @

vendor/wikimedia/less.php/lib/Less/Tree/Property.php

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