PHPStan\Analyser\NodeScopeResolver::processTraitUse PHP Method

processTraitUse() private method

private processTraitUse ( PhpParser\Node\Stmt\TraitUse $node, Scope $classScope, Closure $nodeCallback )
$node PhpParser\Node\Stmt\TraitUse
$classScope Scope
$nodeCallback Closure
    private function processTraitUse(Node\Stmt\TraitUse $node, Scope $classScope, \Closure $nodeCallback)
    {
        foreach ($node->traits as $trait) {
            $traitName = (string) $trait;
            if (!$this->broker->hasClass($traitName)) {
                continue;
            }
            $traitReflection = $this->broker->getClass($traitName);
            $fileName = $traitReflection->getNativeReflection()->getFileName();
            $parserNodes = $this->parser->parseFile($fileName);
            $classScope = $classScope->changeAnalysedContextFile(sprintf('%s (in context of %s)', $fileName, $classScope->getClass() !== null ? sprintf('class %s', $classScope->getClass()) : 'anonymous class'));
            $this->processNodes($parserNodes, new Scope($this->broker, $this->printer, $fileName), function (\PhpParser\Node $node) use($traitName, $classScope, $nodeCallback) {
                if ($node instanceof Node\Stmt\Trait_ && $traitName === (string) $node->namespacedName) {
                    $this->processNodes($node->stmts, $classScope, $nodeCallback);
                }
            });
        }
    }