1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #4540 - use correct method when simulating property setting

This commit is contained in:
Matt Brown 2020-11-12 23:56:29 -05:00 committed by Daniil Gentili
parent e1d65ff797
commit 8392fb429c
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 25 additions and 4 deletions

View File

@ -80,7 +80,7 @@ class ExistingAtomicStaticCallAnalyzer
$file_analyzer = $statements_analyzer->getFileAnalyzer();
if ($context->collect_mutations) {
$file_analyzer->getMethodMutations($method_id, $context);
$file_analyzer->getMethodMutations($appearing_method_id, $context);
} else {
// collecting initializations
$local_vars_in_scope = [];
@ -98,14 +98,14 @@ class ExistingAtomicStaticCallAnalyzer
}
}
if (!isset($context->initialized_methods[(string) $method_id])) {
if (!isset($context->initialized_methods[(string) $appearing_method_id])) {
if ($context->initialized_methods === null) {
$context->initialized_methods = [];
}
$context->initialized_methods[(string) $method_id] = true;
$context->initialized_methods[(string) $appearing_method_id] = true;
$file_analyzer->getMethodMutations($method_id, $context);
$file_analyzer->getMethodMutations($appearing_method_id, $context);
foreach ($local_vars_in_scope as $var => $type) {
$context->vars_in_scope[$var] = $type;

View File

@ -2121,6 +2121,27 @@ class PropertyTypeTest extends TestCase
}
}'
],
'skipConstructor' => [
'<?php
class A {
protected string $s;
public function __construct() {
$this->s = "hello";
}
}
class B extends A {}
class C extends B {
public function __construct()
{
parent::__construct();
echo $this->s;
}
}'
],
];
}