Skip to content
Permalink
Browse files

Fix issue when reconciling is_subclass_of on possibly-undefined variable

  • Loading branch information...
muglug committed May 3, 2019
1 parent db227da commit 49acdfc7646e50f4ed82fed7c5fefb2480fee962
Showing with 17 additions and 1 deletion.
  1. +5 −1 src/Psalm/Type/Reconciler.php
  2. +12 −0 tests/ClassStringTest.php
@@ -365,7 +365,11 @@ public static function reconcileTypes(
}
}
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();
@@ -557,6 +557,18 @@ function bar(array $literal_classes, array $generic_classes) {
return array_merge($generic_classes, $literal_classes);
}',
],
'noCrashWithIsSubclassOfNonExistentVariable' => [
'<?php
class A {}
function foo() : void {
/**
* @psalm-suppress UndefinedVariable
* @psalm-suppress MixedArgument
*/
if (!is_subclass_of($s, A::class)) {}
}',
],
];
}

0 comments on commit 49acdfc

Please sign in to comment.
You can’t perform that action at this time.