-
Notifications
You must be signed in to change notification settings - Fork 534
Fix/issue 6758 #1059
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/issue 6758 #1059
Conversation
continue; | ||
} | ||
if (!$fetchNode->name instanceof Node\Identifier) { | ||
if ($fetchNode->class instanceof Node\Expr\Variable && $fetchNode->class->name === '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.
This isn't a general fix for this problem. For example it's not gonna fix this scenario:
$self = $this;
echo $self::HELLO;
or this:
$self = new self();
echo $self::HELLO;
The correct fix this: Acknowledge that ClassConstFetch::$class can contain either a Name or an Expr.
If it's a Name then just check the class name using $scope->resolveName()
. If it's an Expr, get type using $scope->getType()
. If it's a TypeWithClassName, continue and treat it the same way as the Name in ClassConstFetch::$class
.
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.
Thank you for your great pointers.
I didn't even know that the first example is a valid syntax! Fixing now.
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.
Otherwise 👍
public function testBug6758(): void | ||
{ | ||
if (!self::$useStaticReflectionProvider) { | ||
$this->markTestSkipped('Test requires static reflection'); |
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.
Why static reflection? There's nothing special about the file.
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.
Sorry, I'm not sure about why this is need that much, but I added because it failed with
05: Class Bug6758\HelloWorld was not found while trying to analyse it - discovering symbols is probably not configured properly.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbol
without reflection in local testing.
I can run testRule()
with no errors by the way...
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.
You need to run composer dump
after you add a new class.
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.
Thanks.
I didin't know about classmaps...
Thank you! |
fixes phpstan/phpstan#6758