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
Fix comparison with get_class() in traits always evaluate to true #2044
Conversation
60c75b0
to
9e31860
Compare
This pull request has been marked as ready for review. |
9e31860
to
f376d3d
Compare
ac100bc
to
c36760f
Compare
@@ -42,6 +44,10 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, | |||
return new ConstantBooleanType(false); | |||
} | |||
|
|||
if ($scope->isInTrait()) { | |||
return new StringType(); |
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.
We can at least say that it's going to be ClassStringType.
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.
Oh, I just realized this PR is more wrong than right.
- We need to cover the same scenario for
get_class()
without arguments. - We can still return correct specific result for an argument that isn't
$this
.
758dad9
to
deb2c37
Compare
deb2c37
to
108df96
Compare
Thank you. |
closes phpstan/phpstan#3633
see https://3v4l.org/LalXd
test fails without the src change: