1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00

Merge branch '5.22.x' into 5.x

This commit is contained in:
Bruce Weirdan 2024-02-15 23:54:45 +01:00
commit 5f2e9d1bd8
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D
3 changed files with 42 additions and 2 deletions

View File

@ -78,6 +78,7 @@ use function get_class;
use function implode; use function implode;
use function is_int; use function is_int;
use function is_string; use function is_string;
use function ltrim;
use function preg_match; use function preg_match;
use function preg_replace; use function preg_replace;
use function preg_split; use function preg_split;
@ -1932,7 +1933,7 @@ final class ClassLikeNodeScanner
continue; continue;
} }
if ($var_line_parts[0] === ' ') { while (isset($var_line_parts[0]) && $var_line_parts[0] === ' ') {
array_shift($var_line_parts); array_shift($var_line_parts);
} }
@ -1948,11 +1949,12 @@ final class ClassLikeNodeScanner
continue; continue;
} }
if ($var_line_parts[0] === ' ') { while (isset($var_line_parts[0]) && $var_line_parts[0] === ' ') {
array_shift($var_line_parts); array_shift($var_line_parts);
} }
$type_string = implode('', $var_line_parts); $type_string = implode('', $var_line_parts);
$type_string = ltrim($type_string, "* \n\r");
try { try {
$type_string = CommentAnalyzer::splitDocLine($type_string)[0]; $type_string = CommentAnalyzer::splitDocLine($type_string)[0];
} catch (DocblockParseException $e) { } catch (DocblockParseException $e) {

View File

@ -513,6 +513,28 @@ class AnnotationTest extends TestCase
*/ */
class A {}', class A {}',
], ],
'multipeLineGenericArray2' => [
'code' => '<?php
/**
* @psalm-type TRelAlternate =
* list<
* array{
* href: string,
* lang: string
* }
* >
*/
class A {
/** @return TRelAlternate */
public function ret(): array { return []; }
}
$_ = (new A)->ret();
',
'assertions' => [
'$_===' => 'list<array{href: string, lang: string}>',
],
],
'builtInClassInAShape' => [ 'builtInClassInAShape' => [
'code' => '<?php 'code' => '<?php
/** /**

View File

@ -916,6 +916,22 @@ class TypeAnnotationTest extends TestCase
} }
PHP, PHP,
], ],
'typeWithMultipleSpaces' => [
'code' => <<<'PHP'
<?php
/**
* @psalm-type Foo = string
* @psalm-type Bar int
*/
class A {
/**
* @psalm-param Foo $foo
* @psalm-param Bar $bar
*/
public function bar(string $foo, int $bar): void {}
}
PHP,
],
]; ];
} }