src/Php/NodeVisitor.php
protected function buildMethods()
    {
        $refl = new \ReflectionClass($this);
        $enterMethods = [];
        $leaveMethods = [];

        foreach ($refl->getMethods() as $method) {
            $name = $method->getName();
            if (preg_match('/^(enter|leave).+/', $name) && !preg_match('/^(enter|leave)Node$/', $name)) {
                $params = $method->getParameters();
                if ($params && $params[0]->getClass()) {
                    $nodeType = $params[0]->getClass()->getName();
                    if (Text::startsWith($name, 'enter')) {
                        $enterMethods[$nodeType][] = $name;
                    } else {
                        $leaveMethods[$nodeType][] = $name;
                    }
                }
            }
        }
        self::$enterMethods[get_class($this)] = $enterMethods;
        self::$leaveMethods[get_class($this)] = $leaveMethods;
    }
protected function buildMethods()
    {
        $refl = new \ReflectionClass($this);
        $enterMethods = [];
        $leaveMethods = [];

        foreach ($refl->getMethods() as $method) {
            $name = $method->getName();
            if (preg_match('/^(enter|leave).+/', $name) && !preg_match('/^(enter|leave)Node$/', $name)) {
                $params = $method->getParameters();
                if ($params && $params[0]->getClass()) {
                    $nodeType = $params[0]->getClass()->getName();
                    if (Text::startsWith($name, 'enter')) {
                        $enterMethods[$nodeType][] = $name;
                    } else {
                        $leaveMethods[$nodeType][] = $name;
                    }
                }
            }
        }
        self::$enterMethods[get_class($this)] = $enterMethods;
        self::$leaveMethods[get_class($this)] = $leaveMethods;
    }
protected function buildMethods ( ) { $ refl = new \ ReflectionClass ( $ this ) ; $ enterMethods = [ ] ; $ leaveMethods = [ ] ; foreach ( $ refl -> getMethods ( ) as $ method ) { $ name = $ method -> getName ( ) ; if ( preg_match ( '/^(enter|leave).+/' , $ name ) && ! preg_match ( '/^(enter|leave)Node$/' , $ name ) ) { $ params = $ method -> getParameters ( ) ; if ( $ params && $ params [ 0 ] -> getClass ( ) ) { $ nodeType = $ params [ 0 ] -> getClass ( ) -> getName ( ) ; if ( Text :: startsWith ( $ name , 'enter' ) ) { $ enterMethods [ $ nodeType ] [ ] = $ name ; } else { $ leaveMethods [ $ nodeType ] [ ] = $ name ; } } } } self :: $ enterMethods [ get_class ( $ this ) ] = $ enterMethods ; self :: $ leaveMethods [ get_class ( $ this ) ] = $ leaveMethods ; }
collect all rule method according to node type of parameter
collect all rule method according to node type of parameter