Create a node traverser object
@param ContextInterface $context
@return PhpParser\NodeTraverser
339345
public function createTraverser (ContextInterface $context)
	{
		$traverser = new PhpParser\NodeTraverser;

		$stack = new ContextStack ($context);
		
		// scope visitors
		$traverser->addVisitor (new NodeVisitors\ClassVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\InterfaceVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\MethodVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\GlobalFunctionVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\CodeCoverageIgnoreVisitor ($stack, $context));

		// issue visitors
		$traverser->addVisitor (new NodeVisitors\CatchVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\ExitVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\GlobalVarVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\StaticVariableVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\SuperGlobalVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\StaticCallVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\CodeInGlobalSpaceVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\ErrorSuppressionVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\NewVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\IncludeVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\GlobalFunctionCallVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\ClassConstantFetchVisitor ($stack, $context));
		$traverser->addVisitor (new NodeVisitors\StaticPropertyFetchVisitor ($stack, $context));

		return $traverser;
	}
67102
public function context($context = null)
    {
        if (is_null($context) || empty($context) || $context == "this") {
            $context = null;
        } else {
            $this->__contextAwareContext = $context;
        }
        return $this;
    }
1284639
public static function fromParts( $context, $nodeTest, $iter )
	{
		$result = new ChildOverDescendantsNodeIterator();
		$result->fromChildOverDescendantsNodeIteratorParts( $context, $nodeTest, $iter );
		return $result;
	}
263781
public function evaluateChildNodes(RenderingContextInterface $renderingContext)
    {
        $output = null;
        /** @var $subNode NodeInterface */
        foreach ($this->childNodes as $subNode) {
            if ($output === null) {
                $output = $subNode->evaluate($renderingContext);
            } else {
                if (is_object($output)) {
                    if (!method_exists($output, '__toString')) {
                        throw new Parser\Exception('Cannot cast object of type "' . get_class($output) . '" to string.', 1248356140);
                    }
                    $output = $output->__toString();
                } else {
                    $output = (string) $output;
                }
                $subNodeOutput = $subNode->evaluate($renderingContext);

                if (is_object($subNodeOutput)) {
                    if (!method_exists($subNodeOutput, '__toString')) {
                        throw new Parser\Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1273753083);
                    }
                    $output .= $subNodeOutput->__toString();
                } else {
                    $output .= (string) $subNodeOutput;
                }
            }
        }
        return $output;
    }
184284
protected function route(Context $context)
    {
        $this->logger->debug('kernel.route: find route from http query');

        // logic already specified
        if($context->logic) {
            $this->logger->debug('kernel.route: forward to #' . $context->logic->name . ', skip routing');
            return $context;
        }

        // find route
        $query = $context->request->method . ' ' . $context->request->uri->path;
        $route = $this->router->find($query);

        // 404
        if(!$route) {
            throw new NotFoundException('No route found for query ' . $query);
        }

        // update context
        $context->route = $route;
        $context->params = $route->params;
        $context->logic = $route->resource;

        $this->logger->debug('kernel.route: #' . $context->logic->name . ' found for query ' . $query);

        return $context;
    }
724136
public function createFromNode(NodeInterface $node)
    {
        $item = $this->createItem($node->getName(), $node->getOptions());
        /* @var $childNode NodeInterface */
        foreach ($node->getChildren() as $childNode) {
            $item->addChild($this->createFromNode($childNode));
        }

        return $item;
    }
561185
public function getTraverser()
    {
        if (!$this->traverser) {
            $this->traverser = new NodeTraverser;
            $this->traverser->addVisitor(new NameResolver);
            $this->traverser->addVisitor($this->getVisitor());
        }

        return $this->traverser;
    }
134988
public function getContext(ModelContextInterface $context = null)
    {
        $context = new ModelContext($context);
        $context->setState($this->getState());
        $context->setIdentityKey($this->_identity_key);

        return $context;
    }
915529
public static function getClosestAggregateNode(NodeInterface $node)
    {
        while ($node !== null && !$node->getNodeType()->isAggregate()) {
            $node = $node->getParent();
        }
        return $node;
    }
184829
public function goBegin(Context $context = null)
    {
        $id = $this->bind($context);
        return $this->getDBQueryBuilder($context)->go($id, 'begin');
    }
534991
public function getContext(ControllerContextInterface $context = null)
    {
        $context = new ControllerContext($context);
        $context->setRequest($this->getRequest());
        $context->setResponse($this->getResponse());
        $context->setUser($this->getUser());

        return $context;
    }
457008
protected function processChild(\DOMElement $element, ContextInterface $context)
    {
        if ($element->hasAttribute('itemscope') && empty($element->getAttribute('itemprop'))) {
            $context = $this->createAndAddChild($element, $context);
        }

        return $context;
    }
514271
public function beforeAdoptNode(NodeInterface $node, Context $context, $recursive)
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        if ($this->currentlyAdopting === 0) {
            /* @var $nodeEvent NodeEvent */
            $nodeEvent = $this->eventEmittingService->emit(self::NODE_ADOPT, [
                'targetWorkspace' => $context->getWorkspaceName(),
                'targetDimensions' => $context->getTargetDimensions(),
                'recursive' => $recursive
            ], NodeEvent::class);
            $nodeEvent->setNode($node);
            $this->eventEmittingService->pushContext();
        }

        $this->currentlyAdopting++;
    }
402939
public function assemble(ContextInterface $context)
    {
        $class = $context->getClass();
        $property = $context->getProperty();
        try {
            $methodName = Normalizer::generatePropertyMethod('with', $property->getName());
            $class->removeMethod($methodName);
            $lines = [
                sprintf('$new = clone $this;'),
                sprintf('$new->%1$s = $%1$s;', $property->getName()),
                '',
                sprintf('return $new;'),
            ];
            $parameterOptions = ['name' => $property->getName()];
            if ($this->options->useTypeHints()) {
                $parameterOptions['type'] = $property->getType();
            }
            $class->addMethodFromGenerator(
                MethodGenerator::fromArray(
                    [
                        'name' => $methodName,
                        'parameters' => [$parameterOptions],
                        'visibility' => MethodGenerator::VISIBILITY_PUBLIC,
                        'body' => implode($class::LINE_FEED, $lines),
                        'docblock' => DocBlockGeneratorFactory::fromArray([
                            'tags' => [
                                [
                                    'name' => 'param',
                                    'description' => sprintf('%s $%s', $property->getType(), $property->getName()),
                                ],
                                [
                                    'name' => 'return',
                                    'description' => $class->getName(),
                                ],
                            ],
                        ]),
                    ]
                )
            );
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }
196062
public function getContext(ControllerContextInterface $context = null)
    {
        $context = new ControllerContextModel(parent::getContext($context));
        return $context;
    }
586218
protected function createAndAddChild(\DOMElement $element, ContextInterface $context)
    {
        $thing = $this->getThing(
            trim($element->getAttribute('itemtype')) ?: null,
            trim($element->getAttribute('itemid')) ?: null,
            $context
        );

        // Process item references
        $this->processItemReferences($element, $context, $thing);

        // Add the new thing as a child to the current context
        // and set the thing as parent thing for nested iterations
        return $context->addChild($thing)->setParentThing($thing);
    }
788520
public static function CreateFilter( $context, $node, $predicateList )
	{
		if ( count( $predicateList ) == 1 )
		{
			/**
			 * @var AbstractNode $predicate
			 */
			$predicate = AbstractNode::Create( $context, $predicateList[0] );
			if ( $predicate instanceof ValueNode )
			{
				/**
				 * @var ValueNode $numexpr
				 */
				$numexpr = $predicate;
				if ( is_int( $numexpr->getContent() ) || $numexpr->getContent() instanceof Integer )
				{
					/**
					 * @var PathStep $res
					 */
					$res = PathStep::Create( $context, $node );
					$res->AddLast( PathStep::fromNodeType( $numexpr->getContent(), XPath2ExprType::PositionFilter ) );
					return $res;
				}
			}
		}

		/**
		 * @var AbstractNode $filterExpr
		 */
		$filterExpr = new FilterExprNode( $context, $node, $predicateList );
		// return new PathStep( $filterExpr );
		return PathStep::fromNode( $filterExpr );
	}