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:
parent
db227dab06
commit
49acdfc764
@ -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();
|
||||
|
@ -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)) {}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user