From ff17dcf1eec9052a469a28e8d4c3ac235995dab7 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 2 Oct 2016 10:26:13 -0400 Subject: [PATCH] Fix while loop unset issue --- src/Psalm/Checker/StatementsChecker.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Psalm/Checker/StatementsChecker.php b/src/Psalm/Checker/StatementsChecker.php index 5ec7062e6..d0dd7463e 100644 --- a/src/Psalm/Checker/StatementsChecker.php +++ b/src/Psalm/Checker/StatementsChecker.php @@ -2030,12 +2030,14 @@ class StatementsChecker continue; } - if ($while_context->vars_in_scope[$var]->isMixed()) { - $context->vars_in_scope[$var] = $while_context->vars_in_scope[$var]; - } + if (isset($while_context->vars_in_scope[$var])) { + if ($while_context->vars_in_scope[$var]->isMixed()) { + $context->vars_in_scope[$var] = $while_context->vars_in_scope[$var]; + } - if ((string) $while_context->vars_in_scope[$var] !== (string) $type) { - $context->vars_in_scope[$var] = Type::combineUnionTypes($while_context->vars_in_scope[$var], $type); + if ((string) $while_context->vars_in_scope[$var] !== (string) $type) { + $context->vars_in_scope[$var] = Type::combineUnionTypes($while_context->vars_in_scope[$var], $type); + } } }