Merge pull request #71 from weirdan/fix-build-failures

Fix build failures
This commit is contained in:
Bruce Weirdan 2020-05-04 07:44:02 +03:00 committed by GitHub
commit f40da72269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Psalm\PhpUnitPlugin\Hooks;
use PhpParser\Comment\Doc;
use PHPUnit\Framework\TestCase;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
@ -502,7 +503,10 @@ class TestCaseHandler implements
if ($docblock) {
try {
$parsed_comment = DocComment::parse((string)$docblock->getReformattedText(), $docblock->getLine());
$parsed_comment = DocComment::parse(
(string)$docblock->getReformattedText(),
self::getCommentLine($docblock)
);
} catch (DocblockParseException $e) {
return [];
}
@ -530,4 +534,13 @@ class TestCaseHandler implements
$codebase->scanner->queueClassLikeForScanning($fq_class_name, $file_path);
}
}
private static function getCommentLine(Doc $docblock): int
{
if (method_exists($docblock, 'getStartLine')) {
return (int) $docblock->getStartLine();
}
/** @psalm-suppress DeprecatedMethod */
return $docblock->getLine();
}
}