Skip to content

Improve ::class type for final classes#1699

Merged
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
rvanvelzen:final-class-const
Sep 5, 2022
Merged

Improve ::class type for final classes#1699
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
rvanvelzen:final-class-const

Conversation

@rvanvelzen
Copy link
Copy Markdown
Contributor

No description provided.

@rvanvelzen rvanvelzen marked this pull request as ready for review September 5, 2022 11:16
@ondrejmirtes ondrejmirtes merged commit d0fb570 into phpstan:1.8.x Sep 5, 2022
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

$t = new Test(new A());
$class = $t->value::class;
assertType('class-string<Bug7698\A>|class-string<Bug7698\B>', $class);
assertType("'Bug7698\\\\A'|'Bug7698\\\\B'", $class);
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.

Don't we loose knowledge here, that the type involved is not just a regular string but a class-string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, that's what the 2nd parameter of ConstantStringType constructor is.

@rvanvelzen rvanvelzen deleted the final-class-const branch September 6, 2022 09:26
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.

3 participants