/** * @dataProvider getPropertyTests */ public function testProperties($name) { $ast = $this->analyzeAst('TypeInference/' . $name . '.php'); $nodes = \PHPParser_Finder::create($ast)->find('Expr_PropertyFetch[name=foo]'); $this->assertSame(2, count($nodes), 'There are 4 accesses to the "foo" property.'); $expectedType = $this->registry->getClass('Foo'); foreach ($nodes as $node) { $this->assertTrue($expectedType->equals($actualType = $node->getAttribute('type')), 'Expected type "' . $expectedType . '", but got "' . $actualType . '" for property access on line ' . $node->getLine() . '.'); } $nodes = \PHPParser_Finder::create($ast)->find('Stmt_PropertyProperty[name=foo]'); $this->assertSame(1, count($nodes), 'There are two properties named "foo".'); foreach ($nodes as $node) { $this->assertTrue($expectedType->equals($actualType = $node->getAttribute('type')), 'Expected type "' . $expectedType . '", but got "' . $actualType . '" for property declartion on line ' . $node->getLine() . '.'); } }
private function handleGoto(\PHPParser_Node_Stmt_Goto $node) { $parent = $node->getAttribute('parent'); while (!NodeUtil::isScopeCreator($parent)) { $newParent = $parent->getAttribute('parent'); if (null === $newParent) { break; } $parent = $newParent; } $nodes = \PHPParser_Finder::create(array($parent))->find('Stmt_Label[name=' . $node->name . ']'); if (!$nodes) { return; } $this->graph->connectIfNotConnected($node, GraphEdge::TYPE_UNCOND, $nodes[0]); }