public function analyzeGraphs(array $graphs) { $state = new State(array_values($graphs)); echo "Determining Variable Types\n"; $typeReconstructor = new TypeReconstructor(); $typeReconstructor->resolve($state); return $state; }
/** @dataProvider provideTestParseAndDump */ public function testParseAndDump($name, $code, $expectedDump) { $astTraverser = new PhpParser\NodeTraverser(); $astTraverser->addVisitor(new PhpParser\NodeVisitor\NameResolver()); $parser = new Parser((new ParserFactory())->create(ParserFactory::PREFER_PHP7), $astTraverser); $block = $parser->parse($code, 'foo.php'); $traverser = new Traverser(); $traverser->addVisitor(new Visitor\Simplifier()); $traverser->traverse($block); $reconstructor = new TypeReconstructor(); $state = new State([$block]); $reconstructor->resolve($state); $printer = new Printer\Text(); $this->assertEquals($this->canonicalize($expectedDump), $this->canonicalize($printer->printCfg([$block]))); }