Php – Autocomplete for PHP Objects with classes in PDT/Netbeans

autocompletenetbeansphp

When I define an object of a class using new like this

$blah = new Whatever();

I get autocomplete for $blah. But how do I do it when I have $blah as a function parameter? Without autocomplete I am incomplete.

Edit: How do I do it if it's in an include and PDT or Netbeans can't figure it out? Is there any way to declare types for variables in PHP?

Best Solution

Method in first comment is called "type hinting", but you should use that wisely. Better solution is phpDoc.

/**
 * Some description of function behaviour.
 *
 * @param Whatever $blah
 */
public function myFunction($blah)
{
    $blah-> 
    // Now $blah is Whatever object, autocompletion will work.
}

You can also use an inline phpDoc comment which does exactly the same thing.

public function myFunction($blah)
{
    /* @var $blah Whatever  */
    $blah-> 
    // Now $blah is Whatever object, autocompletion will work.
}