Skip to content

Commit

Permalink
Merge pull request #71 from weirdan/fix-build-failures
Browse files Browse the repository at this point in the history
Fix build failures
  • Loading branch information
weirdan authored May 4, 2020
2 parents 5ea01f2 + 5590278 commit f40da72
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Hooks/TestCaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Psalm\PhpUnitPlugin\Hooks;

use PhpParser\Comment\Doc;
use PHPUnit\Framework\TestCase;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down Expand Up @@ -502,7 +503,10 @@ private static function getSpecials(ClassMethod $method): array

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 [];
}
Expand Down Expand Up @@ -530,4 +534,13 @@ private static function queueClassLikeForScanning(
$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();
}
}

0 comments on commit f40da72

Please # to comment.