[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/lessphp/Tree/ -> Variable.php (source)

   1  <?php
   2  
   3  /**
   4   * Variable
   5   *
   6   * @package Less
   7   * @subpackage tree
   8   */
   9  class Less_Tree_Variable extends Less_Tree{
  10  
  11      public $name;
  12      public $index;
  13      public $currentFileInfo;
  14      public $evaluating = false;
  15      public $type = 'Variable';
  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  
  28          if( $this->name[1] === '@' ){
  29              $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1, $this->currentFileInfo);
  30              $name = '@' . $v->compile($env)->value;
  31          }else{
  32              $name = $this->name;
  33          }
  34  
  35          if ($this->evaluating) {
  36              throw new Less_Exception_Compiler("Recursive variable definition for " . $name, null, $this->index, $this->currentFileInfo);
  37          }
  38  
  39          $this->evaluating = true;
  40  
  41          foreach($env->frames as $frame){
  42              if( $v = $frame->variable($name) ){
  43                  $r = $v->value->compile($env);
  44                  $this->evaluating = false;
  45                  return $r;
  46              }
  47          }
  48  
  49          throw new Less_Exception_Compiler("variable " . $name . " is undefined in file ".$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo);
  50      }
  51  
  52  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1