-
Notifications
You must be signed in to change notification settings - Fork 519
Improve type inference for $object::class === static::class #1761
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
base: 1.9.x
Are you sure you want to change the base?
Conversation
src/Analyser/TypeSpecifier.php
Outdated
if ( | ||
$expr->left instanceof FuncCall | ||
&& $expr->left->name instanceof Name | ||
&& strtolower($expr->left->name->toString()) === 'get_class' | ||
&& isset($expr->left->getArgs()[0]) | ||
&& $rightType instanceof ConstantStringType | ||
) { | ||
return $this->specifyTypesInCondition( | ||
$scope, | ||
new Instanceof_( | ||
$expr->left->getArgs()[0]->value, | ||
new Name($rightType->getValue()), | ||
), | ||
$context, | ||
$rootExpr, | ||
); | ||
} |
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.
5d4fc09
to
5154e11
Compare
@@ -347,6 +348,59 @@ public function specifyTypesInCondition( | |||
$rootExpr, | |||
); | |||
} | |||
if ( |
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.
if you move this block into the upper if ($expressions !== null) {
block, it would work independent of operand order.
atm the code only works for if ($other::class === static::class) {
, within the upper IF it would also work for if (static::class === $other::class) {
5154e11
to
8cc986c
Compare
No description provided.