mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #1799 - support trailing commas in object-like docblock types
This commit is contained in:
parent
1bdd444ce6
commit
b12f05185a
@ -76,7 +76,9 @@ class CommentAnalyzer
|
||||
$type_start = $offset + $comment->getFilePos();
|
||||
$type_end = $type_start + strlen($line_parts[0]);
|
||||
|
||||
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||
$line_parts[0] = preg_replace('@^[ \t]*\*@m', '', $line_parts[0]);
|
||||
$line_parts[0] = preg_replace('/,\n\s+\}/', '}', $line_parts[0]);
|
||||
$line_parts[0] = str_replace("\n", '', $line_parts[0]);
|
||||
|
||||
if ($line_parts[0] === ''
|
||||
|| ($line_parts[0][0] === '$'
|
||||
@ -308,7 +310,9 @@ class CommentAnalyzer
|
||||
$start = $offset + $comment->getFilePos();
|
||||
$end = $start + strlen($line_parts[0]);
|
||||
|
||||
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||
$line_parts[0] = preg_replace('@^[ \t]*\*@m', '', $line_parts[0]);
|
||||
$line_parts[0] = preg_replace('/,\n\s+\}/', '}', $line_parts[0]);
|
||||
$line_parts[0] = str_replace("\n", '', $line_parts[0]);
|
||||
|
||||
if ($line_parts[0] === ''
|
||||
|| ($line_parts[0][0] === '$'
|
||||
|
@ -1014,6 +1014,30 @@ class AnnotationTest extends TestCase
|
||||
$a->bar();
|
||||
}'
|
||||
],
|
||||
'allowClosingComma' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param array{
|
||||
* foo: string,
|
||||
* bar: string,
|
||||
* baz: array{
|
||||
* a: int,
|
||||
* },
|
||||
* } $foo
|
||||
*/
|
||||
function foo(array $foo) : int {
|
||||
return count($foo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array{
|
||||
* foo:string,
|
||||
* bar:string,
|
||||
* baz:string,
|
||||
* } $foo
|
||||
*/
|
||||
$foo = ["foo" => "", "bar" => "", "baz" => ""];'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user