vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Intelephense should not display static functions on a class instance

Open carlosdubus opened this issue 5 years ago • 4 comments

I'm not sure if this is because of the nature of PHP so let me know. I don't think Intelephense should autocomplete static functions on a class instance. At least it should display a difference between the two. See below. I can't tell which functions are static and which aren't just by looking at the autocomplete box.

To Reproduce

class A {
	public static function aStaticFoo() {}
	public function bFoo() {}
}

$a = new A();
$a-> // here Intelephense shows aStaticFoo() the same way it shows bFoo()

Expected behavior Shows only instance methods, or at leave static methods to the bottom with a visual difference.

Screenshots alt text

Platform and version Intelephense 1.3.6

carlosdubus avatar Dec 19 '19 00:12 carlosdubus

This used to be the case but it was changed due to confusion over why some methods weren't showing. For example phpunit asserts are all static methods but all the online documentation shows them called with ->.

Styling them different would be a vscode thing and the language server protocol would need to specify modifiers that could be sent to identify as static before something like this could be implemented.

Good idea about sorting last though, I'll keep this open to track that addition.

bmewburn avatar Dec 19 '19 08:12 bmewburn

Ah phpunit... I see. The only reason I'm bothered by this is because when using Laravel Eloquent Model, I get a lot of static methods from the base class. I guess showing static functions fixes phpunit but makes Laravel Model ugly. Great extension either way. Thanks!

carlosdubus avatar Dec 20 '19 23:12 carlosdubus

Duplicated #601 (don't know if this will be improved in the future, don't think so)

d8vjork avatar Feb 05 '20 22:02 d8vjork

Could there be an option in the settings (not) to display static methods in a non-static environment (arrow)? It would be advantageous to easily distinguish between static and non-static methods. Or perhaps sorted last/different icon?

runelanghelle avatar Jan 21 '24 22:01 runelanghelle

tracking in #2538

bmewburn avatar Mar 19 '24 03:03 bmewburn