From 49acdfc7646e50f4ed82fed7c5fefb2480fee962 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 3 May 2019 09:09:51 -0400 Subject: [PATCH] Fix issue when reconciling is_subclass_of on possibly-undefined variable --- src/Psalm/Type/Reconciler.php | 6 +++++- tests/ClassStringTest.php | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 0809a3b9c..f02d3800a 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -365,7 +365,11 @@ class Reconciler } } - return Type::parseString($new_var_type, null, $template_type_map); + try { + return Type::parseString($new_var_type, null, $template_type_map); + } catch (\Exception $e) { + return Type::getMixed(); + } } return Type::getMixed(); diff --git a/tests/ClassStringTest.php b/tests/ClassStringTest.php index e2d3d4c17..c46f2e45d 100644 --- a/tests/ClassStringTest.php +++ b/tests/ClassStringTest.php @@ -557,6 +557,18 @@ class ClassStringTest extends TestCase return array_merge($generic_classes, $literal_classes); }', ], + 'noCrashWithIsSubclassOfNonExistentVariable' => [ + '