mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
parent
e97a9c86eb
commit
32d526bde9
@ -160,6 +160,13 @@ class ClosureAnalyzer extends FunctionLikeAnalyzer
|
||||
: Type::getMixed();
|
||||
|
||||
$use_context->vars_possibly_in_scope[$use_var_id] = true;
|
||||
|
||||
foreach ($context->vars_in_scope as $var_id => $type) {
|
||||
if (preg_match('/^\$' . $use->var->name . '[\[\-]/', $var_id)) {
|
||||
$use_context->vars_in_scope[$var_id] = clone $type;
|
||||
$use_context->vars_possibly_in_scope[$var_id] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
|
@ -519,6 +519,21 @@ class ClosureTest extends TestCase
|
||||
[],
|
||||
'7.4'
|
||||
],
|
||||
'rememberParentAssertions' => [
|
||||
'<?php
|
||||
class A {
|
||||
public ?A $a = null;
|
||||
public function foo() : void {}
|
||||
}
|
||||
|
||||
function doFoo(A $a): void {
|
||||
if ($a->a instanceof A) {
|
||||
function () use ($a): void {
|
||||
$a->a->foo();
|
||||
};
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user