Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/DefinitionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -906,11 +906,12 @@ public function resolveClassNameToType($class): Type
// Anonymous class
return new Types\Object_;
}
$className = (string)$class->getResolvedName();

if ($className === 'static') {
if ($class instanceof PhpParser\Token && $class->kind === PhpParser\TokenKind::StaticKeyword) {
// `new static`
return new Types\Static_;
}
$className = (string)$class->getResolvedName();

if ($className === 'self' || $className === 'parent') {
Copy link
Owner

Choose a reason for hiding this comment

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

can these be checked through TokenKind too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There aren't TokenKinds for self and parent. I don't know why. They are parsed as QualifiedNames.

$classNode = $class->getFirstAncestor(Node\Statement\ClassDeclaration::class);
if ($className === 'parent') {
Expand Down