1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix issue when reconciling is_subclass_of on possibly-undefined variable

This commit is contained in:
Matthew Brown 2019-05-03 09:09:51 -04:00
parent db227dab06
commit 49acdfc764
2 changed files with 17 additions and 1 deletions

View File

@ -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();

View File

@ -557,6 +557,18 @@ class ClassStringTest extends TestCase
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)) {}
}',
],
];
}