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

Fix #4315 - prevent crash when setting unknown property in finally

This commit is contained in:
Matt Brown 2020-10-13 08:32:26 -04:00 committed by Daniil Gentili
parent 278a306681
commit 399a7bfd11
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 8 additions and 1 deletions

View File

@ -479,7 +479,7 @@ class TryAnalyzer
$finally_context->vars_in_scope[$var_id],
$codebase
);
} else {
} elseif (isset($finally_context->vars_in_scope[$var_id])) {
$context->vars_in_scope[$var_id] = clone $finally_context->vars_in_scope[$var_id];
}
}

View File

@ -365,6 +365,13 @@ class TryCatchTest extends TestCase
}
}'
],
'suppressUndefinedVarInFinally' => [
'<?php
try {} finally {
/** @psalm-suppress UndefinedGlobalVariable, MixedPropertyAssignment */
$event->end = null;
}',
],
];
}