mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix notice for certain invalid docblocks (#5709)
Fixes vimeo/psalm#5680
This commit is contained in:
parent
0189420814
commit
27ea40eda0
@ -59,7 +59,7 @@ class FunctionLikeDocblockParser
|
||||
|
||||
if (count($line_parts) > 1) {
|
||||
if (preg_match('/^&?(\.\.\.)?&?\$[A-Za-z0-9_]+,?$/', $line_parts[1])
|
||||
&& $line_parts[0][0] !== '{'
|
||||
&& ($line_parts[0] === '' || $line_parts[0][0] !== '{')
|
||||
) {
|
||||
$line_parts[1] = str_replace('&', '', $line_parts[1]);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
use Psalm\Exception\IncorrectDocblockException;
|
||||
use Psalm\Internal\RuntimeCaches;
|
||||
use Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockParser;
|
||||
|
||||
@ -54,4 +55,16 @@ class FunctionLikeDocblockParserTest extends BaseTestCase
|
||||
$this->assertTrue(isset($function_docblock->params[1]['description']));
|
||||
$this->assertSame('The blah tags that has a very long multiline description.', $function_docblock->params[1]['description']);
|
||||
}
|
||||
|
||||
public function testMisplacedVariableOnNextLine(): void
|
||||
{
|
||||
$doc = '/**
|
||||
* @param
|
||||
* $p
|
||||
*/';
|
||||
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
||||
$this->expectException(IncorrectDocblockException::class);
|
||||
$this->expectExceptionMessage('Misplaced variable');
|
||||
FunctionLikeDocblockParser::parse($php_parser_doc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user