mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 09:37:59 +01:00
Merge pull request #10713 from weirdan/fix_psalm_type
This commit is contained in:
commit
e9dad66e11
@ -78,6 +78,7 @@ use function get_class;
|
||||
use function implode;
|
||||
use function is_int;
|
||||
use function is_string;
|
||||
use function ltrim;
|
||||
use function preg_match;
|
||||
use function preg_replace;
|
||||
use function preg_split;
|
||||
@ -1932,7 +1933,7 @@ final class ClassLikeNodeScanner
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($var_line_parts[0] === ' ') {
|
||||
while (isset($var_line_parts[0]) && $var_line_parts[0] === ' ') {
|
||||
array_shift($var_line_parts);
|
||||
}
|
||||
|
||||
@ -1948,11 +1949,12 @@ final class ClassLikeNodeScanner
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($var_line_parts[0] === ' ') {
|
||||
while (isset($var_line_parts[0]) && $var_line_parts[0] === ' ') {
|
||||
array_shift($var_line_parts);
|
||||
}
|
||||
|
||||
$type_string = implode('', $var_line_parts);
|
||||
$type_string = ltrim($type_string, "* \n\r");
|
||||
try {
|
||||
$type_string = CommentAnalyzer::splitDocLine($type_string)[0];
|
||||
} catch (DocblockParseException $e) {
|
||||
|
@ -513,6 +513,28 @@ class AnnotationTest extends TestCase
|
||||
*/
|
||||
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' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
|
@ -916,6 +916,22 @@ class TypeAnnotationTest extends TestCase
|
||||
}
|
||||
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,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user