How to mark array value types in PHP (Java)Doc?
Posted
by Christian Sciberras
on Stack Overflow
See other posts from Stack Overflow
or by Christian Sciberras
Published on 2010-06-17T10:37:57Z
Indexed on
2010/06/17
10:43 UTC
Read the original article
Hit count: 317
It might be a bit difficult to explain, so I'll give some example code. Note that I'm using NetBeans IDE (latest).
class Dummy {
public function say(){ }
}
/**
* Builds dummy class and returns it.
* @return Dummy The dummy class.
*/
function say_something(){
return new Dummy();
}
$s=say_something();
While developing in netbeans I can invoke auto-complete by hitting ctrl+space after typing "$s->". In the the hint window that follows, there is the item "say()". This is because the javadoc says say_something returns a Dummy and NetBeans parsed Dummy class to know that it has a method called "say()".
So far so good.
My problem is with arrays. Example code follows:
/**
* Builds array of 2 dummy classes and returns it.
* @return Array The dummy class. (*)
*/
function say_something2(){
return array(new Dummy(),new Dummy());
}
$s=say_something2();
If I try the auto-complete thing again but with "$s[0]->" instead, I don't get the methods fro Dummy class. This is because in the JavaDoc I only said that it is an array, but not the values' type.
So the question would be, is there any JavaDoc syntax, cheat, whatever which allows me to tell JavaDoc what type of variables to expect in an array?
© Stack Overflow or respective owner