mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 17:52:45 +01:00
Fix for spaces after , in multiline docblock types
This commit is contained in:
parent
d05bd5430d
commit
934383e036
@ -261,7 +261,7 @@ final class CommentAnalyzer
|
|||||||
public static function sanitizeDocblockType(string $docblock_type): string
|
public static function sanitizeDocblockType(string $docblock_type): string
|
||||||
{
|
{
|
||||||
$docblock_type = (string) preg_replace('@^[ \t]*\*@m', '', $docblock_type);
|
$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);
|
$docblock_type = (string) preg_replace('/[ \t]+/', ' ', $docblock_type);
|
||||||
|
|
||||||
return trim(str_replace("\n", '', $docblock_type));
|
return trim(str_replace("\n", '', $docblock_type));
|
||||||
|
@ -835,6 +835,20 @@ class TypeAnnotationTest extends TestCase
|
|||||||
'$output===' => 'array{phone: string}',
|
'$output===' => 'array{phone: string}',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'multilineTypeWithExtraSpace' => [
|
||||||
|
'code' => '<?php
|
||||||
|
/**
|
||||||
|
* @psalm-type PhoneType = array{
|
||||||
|
* phone: string, ' . '
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
class Foo {
|
||||||
|
/** @var PhoneType */
|
||||||
|
public static $phone;
|
||||||
|
}
|
||||||
|
$output = Foo::$phone;
|
||||||
|
',
|
||||||
|
],
|
||||||
'combineAliasOfArrayAndArrayCorrectly' => [
|
'combineAliasOfArrayAndArrayCorrectly' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user