Moodle release 2.7.8
[moodle.git] / lib / lessphp / Visitor.php
blob9bd6a7bc8aa2add2e9829643bb812f02f96b5831
1 <?php
3 /**
4 * Visitor
6 * @package Less
7 * @subpackage visitor
8 */
9 class Less_Visitor{
11 var $methods = array();
12 var $_visitFnCache = array();
14 function __construct(){
15 $this->_visitFnCache = get_class_methods(get_class($this));
16 $this->_visitFnCache = array_flip($this->_visitFnCache);
19 function visitObj( $node ){
21 $funcName = 'visit'.$node->type;
22 if( isset($this->_visitFnCache[$funcName]) ){
24 $visitDeeper = true;
25 $this->$funcName( $node, $visitDeeper );
27 if( $visitDeeper ){
28 $node->accept($this);
31 $funcName = $funcName . "Out";
32 if( isset($this->_visitFnCache[$funcName]) ){
33 $this->$funcName( $node );
36 }else{
37 $node->accept($this);
40 return $node;
43 function visitArray( $nodes ){
45 array_map( array($this,'visitObj'), $nodes);
46 return $nodes;