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

Don’t do new isset conversion on try-set vars

This commit is contained in:
Matt Brown 2020-12-02 01:47:49 -05:00 committed by Daniil Gentili
parent 0aeb0ef990
commit 7cc0f65f11
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 11 additions and 0 deletions

View File

@ -491,6 +491,7 @@ class AssertionFinder
&& ($var_type = $source->node_data->getType($isset_var)) && ($var_type = $source->node_data->getType($isset_var))
&& !$var_type->isMixed() && !$var_type->isMixed()
&& !$var_type->possibly_undefined && !$var_type->possibly_undefined
&& !$var_type->possibly_undefined_from_try
&& $var_name !== '$_SESSION' && $var_name !== '$_SESSION'
) { ) {
$if_types[$var_name] = [['!null']]; $if_types[$var_name] = [['!null']];

View File

@ -465,6 +465,16 @@ class TryCatchTest extends TestCase
[], [],
'8.0' '8.0'
], ],
'issetInCatch' => [
'<?php
function foo() : void {
try {
$a = 0;
} catch (Exception $e) {
echo isset($a) ? $a : 1;
}
}'
],
]; ];
} }