-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve is_subclass_of type checks #1321
Conversation
@@ -2,7 +2,15 @@ | |||
|
|||
/** | |||
* @param ($allow_string is false ? object : object|string) $object_or_class | |||
* @param class-string $class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed both, is_a
and is_subclass_of
$class
arg back to string
for max compat with 1.6.x
@@ -42,6 +43,11 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n | |||
$allowStringType = isset($node->getArgs()[2]) ? $scope->getType($node->getArgs()[2]->value) : new ConstantBooleanType(true); | |||
$allowString = !$allowStringType->equals(new ConstantBooleanType(false)); | |||
|
|||
// prevent false-positives in IsAFunctionTypeSpecifyingHelper | |||
if ($objectOrClassType instanceof GenericClassStringType && $classType instanceof GenericClassStringType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obviously this is not a great fix, but with this PR we fix the existing/reported false-positives.
proper support for generic-class-string in is_subclass_of
could be added later.. since there are not existing tests for this case, this should be fine for now
Thank you! |
closes phpstan/phpstan#2755