1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix for spaces after , in multiline docblock types

This commit is contained in:
robchett 2023-10-26 12:39:02 +01:00 committed by Robert Chettleburgh
parent d05bd5430d
commit 934383e036
2 changed files with 15 additions and 1 deletions

View File

@ -261,7 +261,7 @@ final class CommentAnalyzer
public static function sanitizeDocblockType(string $docblock_type): string
{
$docblock_type = (string) preg_replace('@^[ \t]*\*@m', '', $docblock_type);
$docblock_type = (string) preg_replace('/,\n\s+}/', '}', $docblock_type);
$docblock_type = (string) preg_replace('/,[\n\s]+}/', '}', $docblock_type);
$docblock_type = (string) preg_replace('/[ \t]+/', ' ', $docblock_type);
return trim(str_replace("\n", '', $docblock_type));

View File

@ -835,6 +835,20 @@ class TypeAnnotationTest extends TestCase
'$output===' => 'array{phone: string}',
],
],
'multilineTypeWithExtraSpace' => [
'code' => '<?php
/**
* @psalm-type PhoneType = array{
* phone: string, ' . '
* }
*/
class Foo {
/** @var PhoneType */
public static $phone;
}
$output = Foo::$phone;
',
],
'combineAliasOfArrayAndArrayCorrectly' => [
'code' => '<?php