Reputation: 3859
Is there an opportunity, that will allow it to declare a variable in php as a specific object, so that IDEs like Netbeans can detect that Object and suggest me the possible methods and variable in that class?
What I know, is that it works with function like this example:
public static function add(\Event $element) {
//The $element variable is now declared, that it have to be an Event object
}
In the theory, my question looks like this:
\Event $events = EventContainer::getAll();
But unfortunately that wouldn't work.
Upvotes: 1
Views: 85
Reputation: 28722
In eclipse I usually use this pattern:
class Foo {
/**
* @var $barArray \Baz\Bar[]
*/
protected $barArray;
/**
* @var $bar \Baz\Bar
*/
protected $bar
/**
* @return \Baz\Bar
*/
public function getBar()
{
return $this->bar;
}
/**
* @return \Baz\Bar[]
*/
public function getAllBar()
{
return $this->barArray;
}
}
That way eclipse knows by the javadoc what to use in autocomplete. It might work the same in other editors.
Upvotes: 3