Resolve return type of arrow functions (#613)

This commit is contained in:
hoels 2019-06-04 16:25:12 +02:00 committed by Nikita Popov
parent 1bd73cc04c
commit 624f71fa6f
2 changed files with 8 additions and 0 deletions

View File

@ -91,6 +91,7 @@ class NameResolver extends NodeVisitorAbstract
$this->resolveSignature($node); $this->resolveSignature($node);
} elseif ($node instanceof Stmt\ClassMethod } elseif ($node instanceof Stmt\ClassMethod
|| $node instanceof Expr\Closure || $node instanceof Expr\Closure
|| $node instanceof Expr\ArrowFunction
) { ) {
$this->resolveSignature($node); $this->resolveSignature($node);
} elseif ($node instanceof Stmt\Property) { } elseif ($node instanceof Stmt\Property) {

View File

@ -219,6 +219,10 @@ function(A $a) : A {};
function fn3(?A $a) : ?A {} function fn3(?A $a) : ?A {}
function fn4(?array $a) : ?array {} function fn4(?array $a) : ?array {}
fn(array $a): array => $a;
fn(A $a): A => $a;
fn(?A $a): ?A => $a;
A::b(); A::b();
A::$b; A::$b;
A::B; A::B;
@ -263,6 +267,9 @@ function fn3(?\NS\A $a) : ?\NS\A
function fn4(?array $a) : ?array function fn4(?array $a) : ?array
{ {
} }
fn(array $a): array => $a;
fn(\NS\A $a): \NS\A => $a;
fn(?\NS\A $a): ?\NS\A => $a;
\NS\A::b(); \NS\A::b();
\NS\A::$b; \NS\A::$b;
\NS\A::B; \NS\A::B;