mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix parsing of nested callable without args
This commit is contained in:
parent
8d7c365e5f
commit
8b9753a235
@ -99,11 +99,16 @@ class ParseTree
|
||||
break;
|
||||
|
||||
case ')':
|
||||
if ($last_token === '(' && $current_leaf instanceof ParseTree\CallableTree) {
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
if ($current_leaf->parent === null
|
||||
|| $current_leaf->parent instanceof ParseTree\CallableWithReturnTypeTree
|
||||
) {
|
||||
if (!$current_leaf instanceof ParseTree\CallableTree) {
|
||||
var_dump($current_leaf);
|
||||
throw new TypeParseTreeException('Cannot parse generic type');
|
||||
}
|
||||
|
||||
|
@ -752,6 +752,52 @@ class AnnotationTest extends TestCase
|
||||
*/
|
||||
function example(string $x) : void {}',
|
||||
],
|
||||
'megaClosureAnnotationWithoutSpacing' => [
|
||||
'<?php
|
||||
/** @var array{a:Closure():(array<mixed, mixed>|null), b?:Closure():array<mixed, mixed>, c?:Closure():array<mixed, mixed>, d?:Closure():array<mixed, mixed>, e?:Closure():(array{f:null|string, g:null|string, h:null|string, i:string, j:mixed, k:mixed, l:mixed, m:mixed, n:bool, o?:array{0:string}}|null), p?:Closure():(array{f:null|string, g:null|string, h:null|string, q:string, i:string, j:mixed, k:mixed, l:mixed, m:mixed, n:bool, o?:array{0:string}}|null), r?:Closure():(array<mixed, mixed>|null), s:array<mixed, mixed>} */
|
||||
$arr = [];
|
||||
|
||||
$arr["a"]()',
|
||||
],
|
||||
'megaClosureAnnotationWithSpacing' => [
|
||||
'<?php
|
||||
/** @var array{
|
||||
a: Closure() : (array<mixed, mixed>|null),
|
||||
b?: Closure() : array<mixed, mixed>,
|
||||
c?: Closure() : array<mixed, mixed>,
|
||||
d?: Closure() : array<mixed, mixed>,
|
||||
e?: Closure() : (array{
|
||||
f: null|string,
|
||||
g: null|string,
|
||||
h: null|string,
|
||||
i: string,
|
||||
j: mixed,
|
||||
k: mixed,
|
||||
l: mixed,
|
||||
m: mixed,
|
||||
n: bool,
|
||||
o?: array{0:string}
|
||||
}|null),
|
||||
p?: Closure() : (array{
|
||||
f: null|string,
|
||||
g: null|string,
|
||||
h: null|string,
|
||||
q: string,
|
||||
i: string,
|
||||
j: mixed,
|
||||
k: mixed,
|
||||
l: mixed,
|
||||
m: mixed,
|
||||
n: bool,
|
||||
o?: array{0:string}
|
||||
}|null),
|
||||
r?: Closure() : (array<mixed, mixed>|null),
|
||||
s: array<mixed, mixed>
|
||||
} */
|
||||
$arr = [];
|
||||
|
||||
$arr["a"]()',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ class TypeParseTest extends TestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
//parent::setUp();
|
||||
//pae::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -469,6 +469,19 @@ class TypeParseTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testVeryLargeType()
|
||||
{
|
||||
$very_large_type = 'array{a:Closure():(array<mixed, mixed>|null), b?:Closure():array<mixed, mixed>, c?:Closure():array<mixed, mixed>, d?:Closure():array<mixed, mixed>, e?:Closure():(array{f:null|string, g:null|string, h:null|string, i:string, j:mixed, k:mixed, l:mixed, m:mixed, n:bool, o?:array{0:string}}|null), p?:Closure():(array{f:null|string, g:null|string, h:null|string, q:string, i:string, j:mixed, k:mixed, l:mixed, m:mixed, n:bool, o?:array{0:string}}|null), r?:Closure():(array<mixed, mixed>|null), s:array<mixed, mixed>}|null';
|
||||
|
||||
$this->assertSame(
|
||||
$very_large_type,
|
||||
(string) Type::parseString($very_large_type)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestValidCallMapType
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user