diff --git a/lib/PHPCfg/AstVisitor/MagicStringResolver.php b/lib/PHPCfg/AstVisitor/MagicStringResolver.php index f48b774..87da11b 100644 --- a/lib/PHPCfg/AstVisitor/MagicStringResolver.php +++ b/lib/PHPCfg/AstVisitor/MagicStringResolver.php @@ -121,8 +121,8 @@ function ($match) { }, $comment->getText(), ), - $comment->getLine(), - $comment->getFilePos(), + $comment->getStartLine(), + $comment->getStartFilePos(), ); $node->setDocComment($comment); diff --git a/test/PHPCfg/MagicStringResolverTest.php b/test/PHPCfg/MagicStringResolverTest.php new file mode 100644 index 0000000..9138486 --- /dev/null +++ b/test/PHPCfg/MagicStringResolverTest.php @@ -0,0 +1,63 @@ +astParser = (new ParserFactory())->createForNewestSupportedVersion(); + } + + public function testIgnoresInvalidParamTypeInDocComment() + { + $doccomment = <<<'DOC' +/** + * @param Foo\foo bar + */ +DOC; + + $code = <<<'DOC' +astParser->parse($code); + $traverser = new NodeTraverser(); + $traverser->addVisitor(new NameResolver()); + $traverser->addVisitor(new MagicStringResolver()); + $traverser->traverse($ast); + + $this->assertEquals($doccomment, $ast[0]->stmts[0]->stmts[0]->getDocComment()->getText()); + $this->assertEquals(9, $ast[0]->stmts[0]->stmts[0]->stmts[0]->exprs[0]->value); + } +}