1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix method mutation transference

This commit is contained in:
Matthew Brown 2017-01-18 23:19:36 -05:00
parent a2750a92aa
commit de1ce36a5c
2 changed files with 6 additions and 1 deletions

View File

@ -404,7 +404,7 @@ class FileChecker extends SourceChecker implements StatementsSource
throw new \UnexpectedValueException('Method ' . $method_id . ' could not be checked');
}
foreach ($call_context->vars_in_scope as $var => $type) {
foreach ($call_context->vars_possibly_in_scope as $var => $_) {
$this_context->vars_possibly_in_scope[$var] = true;
}

View File

@ -102,6 +102,10 @@ class MethodMutationTest extends PHPUnit_Framework_TestCase
public function barBar() : Response {
$this->setUser();
if (rand(0, 1)) {
$this->title = "hello";
}
return new Response($this->user_viewdata);
}
}'
@ -116,5 +120,6 @@ class MethodMutationTest extends PHPUnit_Framework_TestCase
$this->assertEquals('UserViewData', (string)$method_context->vars_in_scope['$this->user_viewdata']);
$this->assertEquals('string', (string)$method_context->vars_in_scope['$this->user_viewdata->name']);
$this->assertEquals(true, (string)$method_context->vars_possibly_in_scope['$this->title']);
}
}