1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #2545 - fix bug when coming back after analysing method call in constructor

This commit is contained in:
Brown 2020-01-03 11:29:45 -05:00
parent 0e39759ed6
commit 996053cca6
2 changed files with 23 additions and 0 deletions

View File

@ -210,6 +210,8 @@ class CallAnalyzer
}
}
$old_calling_function_id = $context->calling_function_id;
if ($fq_class_name === $source->getFQCLN()) {
$class_analyzer->getMethodMutations(strtolower($method_name), $context);
} else {
@ -226,6 +228,8 @@ class CallAnalyzer
$context->self = $old_self;
}
$context->calling_function_id = $old_calling_function_id;
foreach ($local_vars_in_scope as $var => $type) {
$context->vars_in_scope[$var] = $type;
}

View File

@ -278,6 +278,25 @@ class ImmutableAnnotationTest extends TestCase
takesString($dto->getError());
}'
],
'allowConstructorPrivateUnusedMethods' => [
'<?php
/**
* @psalm-immutable
*/
class PaymentShared
{
/** @var int */
private $commission;
public function __construct()
{
$this->test();
$this->commission = 1;
}
private function test(): void {}
}'
],
];
}