private function newScope() { $globalScope = new Scope($this->getMock('PHPParser_Node')); $this->functionScope = new Scope($this->getMock('PHPParser_Node'), $globalScope); return LinkedFlowScope::createLatticeElement($this->functionScope); }
public function __construct(ControlFlowGraph $cfg, ReverseInterpreterInterface $reverseInterpreter, FunctionInterpreterInterface $functionInterpreter, MethodInterpreter\MethodInterpreterInterface $methodInterpreter, \Scrutinizer\PhpAnalyzer\PhpParser\DocCommentParser $commentParser, Scope $functionScope, TypeRegistry $registry, LoggerInterface $logger = null) { parent::__construct($cfg, self::createJoinOperation()); $this->reverseInterpreter = $reverseInterpreter; $this->functionInterpreter = $functionInterpreter; $this->methodInterpreter = $methodInterpreter; $this->syntacticScope = $functionScope; $this->commentParser = $commentParser; $this->functionScope = LinkedFlowScope::createLatticeElement($functionScope); $this->bottomScope = LinkedFlowScope::createLatticeElement(Scope::createBottomScope($functionScope->getRootNode(), $functionScope->getTypeOfThis())); $this->typeRegistry = $registry; $this->logger = $logger ?: new NullLogger(); }
protected function setUp() { $this->registry = new TypeRegistry(); $this->blockNode = new BlockNode(array()); $this->methodNode = new \PHPParser_Node_Stmt_ClassMethod('foo'); $this->methodNode->stmts = new BlockNode(array()); $this->globalScope = new Scope($this->blockNode); $this->globalScope->declareVar('globalA'); $this->globalScope->declareVar('globalB'); $this->localScope = new Scope($this->methodNode, $this->globalScope); $this->localScope->declareVar('localA'); $this->localScope->declareVar('localB'); $this->globalEntry = LinkedFlowScope::createLatticeElement($this->globalScope); $this->localEntry = LinkedFlowScope::createLatticeElement($this->localScope); }