Question

I do know several posts exists on Netbeans and autocompletion, but none seems to give me the answer to the basic problem i'm facing:

if i do so:

use Project\Foo;
$foo = new Foo;
$foo-> //autocompletes properly all the methods

but if do so:

use Project\Foo;
use Project\Bar;

$foo = $bar->getSomeObject();
$foo-> //doesn't show anything

I've been used to Visual Studio and VB .NET where the keyword AS simplifies the IDE to know which type to autocomplete

How can i explicitly inform Netebans autocompletion i'm manipulating a specific class ?

Any help or link to the same related topic would be much appreciated.

Was it helpful?

Solution

You need to make sure of two things to get hinting to work

class Bar {
    /**
     * @return \Foo
     */
    function getSomeObject() {
        return new \Foo();
     }
}
  1. Set up your code in a project. This lets Netbeans know where your code can be found
  2. Document your code with phpdoc comments. This way, Netbeans has a clear path to follow (in your example, does getSomeObject have an @return declaration?). Netbeans makes this easy. Just type /**<enter> and Netbeans will make the block for you and autocomplete the block as you type
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top