| 1 |
<?php |
| 2 |
/** |
| 3 |
* @private |
| 4 |
* @see less-2.5.3.js#Anonymous.prototype |
| 5 |
*/ |
| 6 |
class Less_Tree_Anonymous extends Less_Tree implements Less_Tree_HasValueProperty { |
| 7 |
/** @var string */ |
| 8 |
public $value; |
| 9 |
/** @var string|null */ |
| 10 |
public $quote; |
| 11 |
/** @var int|null */ |
| 12 |
public $index; |
| 13 |
/** @var bool|null */ |
| 14 |
public $mapLines; |
| 15 |
/** @var array|null */ |
| 16 |
public $currentFileInfo; |
| 17 |
/** @var bool */ |
| 18 |
public $rulesetLike; |
| 19 |
/** @var bool */ |
| 20 |
public $isReferenced; |
| 21 |
|
| 22 |
/** |
| 23 |
* @param string $value |
| 24 |
* @param int|null $index |
| 25 |
* @param array|null $currentFileInfo |
| 26 |
* @param bool|null $mapLines |
| 27 |
* @param bool $rulesetLike |
| 28 |
* @param bool $referenced |
| 29 |
*/ |
| 30 |
public function __construct( $value, $index = null, $currentFileInfo = null, $mapLines = null, $rulesetLike = false, $referenced = false ) { |
| 31 |
$this->value = $value; |
| 32 |
$this->index = $index; |
| 33 |
$this->mapLines = $mapLines; |
| 34 |
$this->currentFileInfo = $currentFileInfo; |
| 35 |
$this->rulesetLike = $rulesetLike; |
| 36 |
// TODO: remove isReferenced and implement $visibilityInfo |
| 37 |
// https://github.com/less/less.js/commit/ead3e29f7b79390ad3ac798bf42195b24919107d |
| 38 |
$this->isReferenced = $referenced; |
| 39 |
} |
| 40 |
|
| 41 |
public function compile( $env ) { |
| 42 |
return new self( $this->value, $this->index, $this->currentFileInfo, $this->mapLines, $this->rulesetLike, $this->isReferenced ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* @param Less_Tree|mixed $x |
| 47 |
* @return int|null |
| 48 |
* @see less-3.13.1.js#Anonymous.prototype.compare |
| 49 |
*/ |
| 50 |
public function compare( $x ) { |
| 51 |
return ( $x instanceof Less_Tree && $this->toCSS() === $x->toCSS() ) ? 0 : null; |
| 52 |
} |
| 53 |
|
| 54 |
public function isRulesetLike() { |
| 55 |
return $this->rulesetLike; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* @see less-3.13.1.js#Anonymous.prototype.genCSS |
| 60 |
*/ |
| 61 |
public function genCSS( $output ) { |
| 62 |
$this->nodeVisible = $this->value !== "" && $this->value !== 0; |
| 63 |
if ( $this->nodeVisible ) { |
| 64 |
$output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines ); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
public function markReferenced() { |
| 69 |
$this->isReferenced = true; |
| 70 |
} |
| 71 |
|
| 72 |
public function getIsReferenced() { |
| 73 |
return !isset( $this->currentFileInfo['reference'] ) || !$this->currentFileInfo['reference'] || $this->isReferenced; |
| 74 |
} |
| 75 |
} |