protected function createContext(Scope $scope, Token $token, $badLine, Index $index) { $context = new Context($scope, $token); $nodes = $this->parser->parse($this->prepareLine($badLine)); if ($token->isObjectOperator() || $token->isStaticOperator() || $token->isMethodCall()) { if (is_array($nodes)) { $workingNode = array_pop($nodes); } else { $workingNode = $nodes; } $isThis = false; if ($workingNode instanceof Variable && $workingNode->name === 'this') { $isThis = true; } if ($workingNode instanceof Name) { $nodeFQCN = $this->useParser->getFQCN($workingNode); if ($scope->getFQCN() instanceof FQCN && $nodeFQCN->toString() === $scope->getFQCN()->toString()) { $isThis = true; } } $types = $this->typeResolver->getChainType($workingNode, $index, $scope); $context->setData([array_pop($types), $isThis, $types, $workingNode]); } if ($token->isUseOperator() || $token->isNamespaceOperator() || $token->isNewOperator()) { $context->setData(trim($token->getSymbol())); } return $context; }
public function setParent(Scope $parent) { $this->parent = $parent; $this->setUses($parent->getUses()); $this->setFQCN($parent->getFQCN()); }