Skip to content

Improve type inference for $object::class === static::class - #1761

Draft
rvanvelzen wants to merge 1 commit into
phpstan:2.3.xfrom
rvanvelzen:static-class-const-equals
Draft

rvanvelzen wants to merge 1 commit into
phpstan:2.3.xfrom
rvanvelzen:static-class-const-equals

Conversation

@rvanvelzen

Copy link
Copy Markdown
Contributor

No description provided.

@rvanvelzen
rvanvelzen marked this pull request as draft September 26, 2022 12:38
Comment thread src/Analyser/TypeSpecifier.php Outdated

@staabm staabm Sep 26, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: I had similar stuff in #1616 - but it did not work out because of the bug I tried to fix in #1396

@rvanvelzen
rvanvelzen force-pushed the static-class-const-equals branch from 5d4fc09 to 5154e11 Compare September 26, 2022 13:41
Comment thread src/Analyser/TypeSpecifier.php Outdated
$rootExpr,
);
}
if (

Copy link
Copy Markdown
Contributor

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) {

@rvanvelzen
rvanvelzen changed the base branch from 1.8.x to 1.9.x October 25, 2022 13:45
@rvanvelzen
rvanvelzen force-pushed the static-class-const-equals branch from 5154e11 to 8cc986c Compare October 25, 2022 13:45
@ondrejmirtes
ondrejmirtes force-pushed the static-class-const-equals branch from 8cc986c to f707077 Compare October 31, 2026 13:43
@ondrejmirtes
ondrejmirtes changed the base branch from 1.9.x to 2.3.x October 31, 2026 13:43
@ondrejmirtes
ondrejmirtes force-pushed the static-class-const-equals branch from f707077 to 2dda630 Compare October 31, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants