Permalink
Browse files
Fix handling of do... while vars defined in try
- Loading branch information
|
@@ -78,8 +78,10 @@ public static function analyze( |
|
|
} |
|
|
|
|
|
if (isset($do_context->vars_in_scope[$var])) { |
|
|
if ($do_context->vars_in_scope[$var]->getId() !== $type->getId()) { |
|
|
if (!$do_context->vars_in_scope[$var]->equals($type)) { |
|
|
$was_possibly_undefined = $do_context->vars_in_scope[$var]->possibly_undefined_from_try; |
|
|
$do_context->vars_in_scope[$var] = Type::combineUnionTypes($do_context->vars_in_scope[$var], $type); |
|
|
$do_context->vars_in_scope[$var]->possibly_undefined_from_try = $was_possibly_undefined; |
|
|
} |
|
|
} |
|
|
} |
|
@@ -144,7 +146,9 @@ function (Clause $c) use ($mixed_var_ids) { |
|
|
|
|
|
foreach ($do_context->vars_in_scope as $var_id => $type) { |
|
|
if (isset($context->vars_in_scope[$var_id])) { |
|
|
$was_possibly_undefined = $type->possibly_undefined_from_try; |
|
|
$context->vars_in_scope[$var_id] = Type::combineUnionTypes($context->vars_in_scope[$var_id], $type); |
|
|
$context->vars_in_scope[$var_id]->possibly_undefined_from_try = $was_possibly_undefined; |
|
|
} |
|
|
} |
|
|
|
|
|
|
@@ -289,6 +289,18 @@ function example() : void { |
|
|
|
|
|
echo $lastException->getMessage();' |
|
|
], |
|
|
'allowDoubleNestedLoop' => [ |
|
|
'<?php |
|
|
function foo() : void { |
|
|
do { |
|
|
try { |
|
|
do { |
|
|
$count = rand(0, 10); |
|
|
} while ($count === 5); |
|
|
} catch (Exception $e) {} |
|
|
} while (rand(0, 1)); |
|
|
}' |
|
|
], |
|
|
]; |
|
|
} |
|
|
|
|
|
0 comments on commit
da03902