Németh Péter
Németh Péter

Reputation: 151

VSCode Class method hint for PHP

I had written classes for a project in different class files.

In the main file I had included these classes, and created instances from them. There is many method in there, and i cannot remember all names.

Is there a solution is VSCode for class method hinting like intellisense, when i typing the object in?

Example:

<?php
include "Some.class.php";
$var = new Some();
$var-> //[CTRL + Space] gives me PHP built in methods, not the class methods.
?>

Upvotes: 5

Views: 6085

Answers (2)

dennis
dennis

Reputation: 630

It is an old question, but it is possible.

I am using the PHP Intelephense extension by Ben Mewburn:

https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client

Install it and you can do something like the following:

<?php

include "Some.class.php";

/**
 * This hints what type the variable is
 * @var \Some $var 
 */
$var = new Some();
$var->

And now you vscode will give you a list of available methods on the object $var

Upvotes: 4

seg-s
seg-s

Reputation: 55

As far as i know there is no such thing yet.

However they are working on plugin support:

We plan to offer plugin support for Visual Studio Code. Thank you for your interests and look for more details in our blog in the coming weeks.

For the preview we are looking for exactly this type of feedback. Keep it coming.

Sean McBreen – VS Code Team Member

link

and adding php intellisense is being discussed:

Hi,

Our extensibility story will definitely support plug-ins for languages like PHP. This will enable authors to develop IntelliSense and Debugging support in additional languages.

That said, we know a lot of PHP users are interested in Code and we are investigating what we can do to make the experience better for PHP as well.

We don’t have a timeline to share currently or any firm roadmap statement but it’s something we are discussing.

Sean McBreen Visual Studio Code – Team Member

link

Note: although a "microsoft made" php intellisense is being discussed, they will allow user made intellisense implementations.

Our extensibility story will support creating IntelliSense and Debugging for additional languages/runtimes.

Sean McBreen Visual Studio Code – Team Member

Upvotes: 1

Related Questions