1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

Add test for #4825

This commit is contained in:
Matt Brown 2020-12-10 13:51:49 -05:00 committed by Daniil Gentili
parent 4f4182897b
commit 972738b772
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 26 additions and 1 deletions

View File

@ -464,7 +464,7 @@ class TryAnalyzer
/** @var string $var_id */
foreach ($finally_context->assigned_var_ids as $var_id => $_) {
if (isset($context->vars_in_scope[$var_id])
&& $finally_context->vars_in_scope[$var_id]
&& isset($finally_context->vars_in_scope[$var_id])
) {
if ($context->vars_in_scope[$var_id]->possibly_undefined
&& $context->vars_in_scope[$var_id]->possibly_undefined_from_try

View File

@ -227,6 +227,31 @@ class PropertyTypeTest extends TestCase
$this->analyzeFile('somefile.php', new Context());
}
public function testNoCrashInTryCatch(): void
{
Config::getInstance()->remember_property_assignments_after_call = false;
$this->addFile(
'somefile.php',
'<?php
function maybeMutates() : void {}
class X {
public int $f = 0;
public function validate(): void {
try {
} finally {
$this->f = 1;
maybeMutates();
}
}
}'
);
$this->analyzeFile('somefile.php', new Context());
}
public function testUniversalObjectCrates(): void
{
Config::getInstance()->addUniversalObjectCrate(\DateTime::class);