[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/lessphp/ -> Visitor.php (source)

   1  <?php
   2  
   3  /**
   4   * Visitor
   5   *
   6   * @package Less
   7   * @subpackage visitor
   8   */
   9  class Less_Visitor{
  10  
  11      protected $methods = array();
  12      protected $_visitFnCache = array();
  13  
  14  	public function __construct(){
  15          $this->_visitFnCache = get_class_methods(get_class($this));
  16          $this->_visitFnCache = array_flip($this->_visitFnCache);
  17      }
  18  
  19  	public function visitObj( $node ){
  20  
  21          $funcName = 'visit'.$node->type;
  22          if( isset($this->_visitFnCache[$funcName]) ){
  23  
  24              $visitDeeper = true;
  25              $this->$funcName( $node, $visitDeeper );
  26  
  27              if( $visitDeeper ){
  28                  $node->accept($this);
  29              }
  30  
  31              $funcName = $funcName . "Out";
  32              if( isset($this->_visitFnCache[$funcName]) ){
  33                  $this->$funcName( $node );
  34              }
  35  
  36          }else{
  37              $node->accept($this);
  38          }
  39  
  40          return $node;
  41      }
  42  
  43  	public function visitArray( $nodes ){
  44  
  45          array_map( array($this,'visitObj'), $nodes);
  46          return $nodes;
  47      }
  48  }
  49  


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