vscode-intelephense
vscode-intelephense copied to clipboard
Traits with a @method tag causes classes using the trait to see that instead of a solid implementation in an Abstract
Describe the bug
If you have a class (e.g. Dog
) that extends an abstract (e.g. AbstractAnimal
), and that abstract has a method (e.g. makeSound
) then when you refer to this method from the Dog
class, the typehints rightly refer to the method in the AbstractAnimal
abstract. However - if you introduce a trait (e.g. AnimalBehaviour
) and at the top of that trait you add a @method
tag referring to makeSound
, then the typehint in your Dog
then switch to referring to the trait.
I get that there is order of precedence with traits (i.e trait methods have priority over methods of extended classes) but I don't think the @method
tag should point the typehint elsewhere.
The biggest unwanted effect of this is that if I do Find all references
in VSCode, the @method
tag (sometimes - not sure why) means that the actual usage of the method does not show in the results.
To Reproduce
abstract class AbstractAnimal
{
public function makeSound(): bool { ... }
}
/**
* @method bool doBark
*/
trait AnimalBehaviourTrait
{
}
class Dog extends AbstractAnimal
{
use AnimalBehaviourTrait;
public function go()
{
$this->makeSound();
}
}
Expected behavior
If you hover over the call to makeSound
in the Dog
class, then the typehint suggests AnimalBehaviourTrait::makeSound()
, and not AbstractAnimal::makeSound()
. If you remove the @method
tag from the trait, then it switches back to what i'd expect.
Platform and version Windows 10 Pro / Intelephense 1.10.2 (premium)