-
Notifications
You must be signed in to change notification settings - Fork 546
Fix get_class return type
#4456
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: 2.1.x
Are you sure you want to change the base?
Conversation
42e1755 to
fa22c84
Compare
ondrejmirtes
left a comment
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.
I feel like a proper solution would be a new Type method. Basically the opposite of getClassStringObjectType. That one goes from class-string<Foo> to Foo.
We need to go from object Foo to class-string<Foo>.
And personally I don't think there's anything wrong with class-string<object{foo: Bar}> because it'd allow for a precise type when doing new on it again.
1ce9e04 to
5702d17
Compare
|
|
||
| public function getClassStringType(): Type | ||
| { | ||
| return new GenericClassStringType($this); |
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.
Not sure if $this should be intersected with ObjectWithoutClassType here.
With the current implementation, generics.php assertions are not changed.
But we might prefer having
assertType(
'class-string<object&T (function PHPStan\Generics\FunctionsAssertType\getClassOnTemplateType(), argument)>|false',
get_class($a)
);
over
assertType(
'class-string<T (function PHPStan\Generics\FunctionsAssertType\getClassOnTemplateType(), argument)>|false',
get_class($a)
);
If later we're doing new on it. WDYT ?
5702d17 to
d30f64a
Compare
I introduced |
|
This pull request has been marked as ready for review. |
Closes #2350
Closes phpstan/phpstan#4890