Skip to content

Fix error getting completions for 'new static' type #405

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

Merged
merged 2 commits into from
Jun 15, 2017
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