diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php index d230ce8dc..a82c01f6e 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php @@ -190,7 +190,7 @@ class FunctionLikeDocblockParser $info->if_this_is = [ 'type' => str_replace("\n", '', $line_parts[0]), - 'line_number' => $comment->getStartLine() + substr_count($comment_text, "\n", 0, $offset), + 'line_number' => $comment->getStartLine() + substr_count($comment_text, "\n", 0, $offset - $comment->getStartFilePos()), ]; } } diff --git a/tests/IfThisIsTest.php b/tests/IfThisIsTest.php index 4316021f2..a17e6f806 100644 --- a/tests/IfThisIsTest.php +++ b/tests/IfThisIsTest.php @@ -9,7 +9,7 @@ class IfThisIsTest extends TestCase /** * @return iterable,error_levels?:string[]}> */ - public function providerValidCodeParse() + public function providerValidCodeParse(): iterable { return [ 'worksAfterConvert' => [ @@ -114,7 +114,7 @@ class IfThisIsTest extends TestCase /** * @return array */ - public function providerInvalidCodeParse() + public function providerInvalidCodeParse(): iterable { return [ 'blocksWithoutConvert' => [