qrcode.chapril.org/vendor/wikimedia/less.php/lib/Less/Tree.php

96 lines
2.1 KiB
PHP
Raw Normal View History

2021-02-15 21:29:38 +01:00
<?php
/**
* Tree
*
2023-07-07 22:33:10 +02:00
* TODO: Callers often use `property_exists(, 'value')` to distinguish
* tree nodes that are considerd value-holding. Refactor this to move
* the 'value' property that most subclasses implement to there, and use
* something else (special value, method, or intermediate class?) to
* signal whether a subclass is considered value-holding.
2021-02-15 21:29:38 +01:00
*/
class Less_Tree {
public $cache_string;
2023-07-07 22:33:10 +02:00
public $parensInOp = false;
public $extendOnEveryPath;
public $allExtends;
2021-02-15 21:29:38 +01:00
public function toCSS() {
$output = new Less_Output();
$this->genCSS( $output );
return $output->toString();
}
/**
* Generate CSS by adding it to the output object
*
* @param Less_Output $output The output
* @return void
*/
public function genCSS( $output ) {
}
2023-07-07 22:33:10 +02:00
public function compile( $env ) {
return $this;
}
2021-02-15 21:29:38 +01:00
/**
2023-07-07 22:33:10 +02:00
* @param Less_Output $output
2021-02-15 21:29:38 +01:00
* @param Less_Tree_Ruleset[] $rules
*/
public static function outputRuleset( $output, $rules ) {
$ruleCnt = count( $rules );
Less_Environment::$tabLevel++;
// Compressed
if ( Less_Parser::$options['compress'] ) {
$output->add( '{' );
for ( $i = 0; $i < $ruleCnt; $i++ ) {
$rules[$i]->genCSS( $output );
}
$output->add( '}' );
Less_Environment::$tabLevel--;
return;
}
// Non-compressed
2023-07-07 22:33:10 +02:00
$tabSetStr = "\n" . str_repeat( Less_Parser::$options['indentation'], Less_Environment::$tabLevel - 1 );
$tabRuleStr = $tabSetStr . Less_Parser::$options['indentation'];
2021-02-15 21:29:38 +01:00
$output->add( " {" );
for ( $i = 0; $i < $ruleCnt; $i++ ) {
$output->add( $tabRuleStr );
$rules[$i]->genCSS( $output );
}
Less_Environment::$tabLevel--;
2023-07-07 22:33:10 +02:00
$output->add( $tabSetStr . '}' );
2021-02-15 21:29:38 +01:00
}
public function accept( $visitor ) {
}
public static function ReferencedArray( $rules ) {
foreach ( $rules as $rule ) {
if ( method_exists( $rule, 'markReferenced' ) ) {
2023-07-07 22:33:10 +02:00
// @phan-suppress-next-line PhanUndeclaredMethod
2021-02-15 21:29:38 +01:00
$rule->markReferenced();
}
}
}
/**
* Requires php 5.3+
*/
public static function __set_state( $args ) {
$class = get_called_class();
$obj = new $class( null, null, null, null );
foreach ( $args as $key => $val ) {
$obj->$key = $val;
}
return $obj;
}
}