Skip to content

Code Completion on method signature returns $this #317

Description

@DarkGhostHunter

Verified on latest main

  • I have confirmed this bug still occurs when built from the latest main branch.

PHPantom version / commit

0.9.0-224-gf4ea6e6

Installation method

Built from source

Operating system

Linux x86_64

Editor

Zed

Bug description

Code-completing a method that returns $this as specified in the PHPDoc, mistakenly is added as a return type, which is invalid.

Image Image

Result:

Image

Steps to reproduce

  1. On Laravel, create any model.
  2. Let code-completion suggest a method that returns $this, like makeFillable
  3. Watch it incorporate the method with $this as return type.

Error output or panic trace


.phpantom.toml

default

Additional context

The completion should return the signature as-is.

#[\Override]
public function makeHidden($attributes)
{
    // ...
}

There may be added a configuration in the future to pick PHPDoc inclusion:

  1. No PHPDoc (default)
  2. Same PHPDoc (copies over the PHPDoc of the original)
  3. Use @inheritdoc (let the developer expand if necessary).

Inclusion of PHPDoc should aid the LSP for method documentation when overriding/expanding just a part of the method, like the return or parameter (especially array shapes), while keeping the rest of the original PHPDoc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions