/** * @test */ public function parseNormal() { $stmts = (include __DIR__ . '/../fixtures/1/Model/Product.php.full.cache'); $namespace = $this->parser->parse($stmts, ''); $this->assertThat($namespace, $this->isType('string')); $this->assertThat($namespace, $this->equalTo('Example\\Model')); }
/** * @param $code * @param $sourcePath * @return Model */ public function parse($code, $sourcePath) { try { $stmts = $this->parser->parse($code); $stmts = $this->traverser->traverse($stmts); if ($this->namespaceParser->match($stmts)) { $this->namespaceParser->parse($stmts, $sourcePath); } } catch (PhpParserError $e) { throw new ParseException('Parse Error: ' . $e->getMessage()); } return $this->model; }