Mikulas Dite
Mikulas Dite

Reputation: 7941

Netbeans php annotations for code completition

What are useful php annotations for Netbeans code completition? I'm already familiar with @return, @param and @throws, but are there any others?

For example, can I set which keys will returned ArrayObject have? In this example, I'd like IDE to suggest me foo and bar after I type get()->. Is it even possible? If so, how?

/**
 * @ ???
 */
function get() {
    $res = new \ArrayObject();
    $res->foo = 1;
    $res->bar = 2;
    return $res;
}

Upvotes: 0

Views: 2452

Answers (2)

Timo Haberkern
Timo Haberkern

Reputation: 4439

Sorry to say in your case there is no way to get this done in any PHP IDE :-(

The only possibilty is to inherit ArrayObject in your own class to get this done but I think you want to set different properties at runntime...

/**
 * @property integer foo
 * @property integer bar
 */
class MyArrayObject extends \ArrayObject
{
}

/**
 * @return MyArrayObject
 */
function get() {
    $res = new MyArrayObject();
    $res->foo = 1;
    $res->bar = 2;
    return $res;
}

Upvotes: 2

Daniel Egeberg
Daniel Egeberg

Reputation: 8382

Have a look at phpDocumentor. That's where those annotations come from. It's kind of like Javadoc, but for PHP.

Upvotes: 2

Related Questions