How to mark array value types in PHP (Java) Doc?

This can be a little tricky to explain, so I'll give you some sample code. Please note that I am using NetBeans (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();

When developing in netbeans, I can cause autocompletion by pressing Ctrl + space after entering "$ s->". The next prompt window has a say () item. This is because javadoc says say_something returns the Dummy and NetBeans Dummy parsed class to know that it has a method called "say ()".

So far so good.

My problem is with arrays. Code example:

/**
 * 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 autocomplete again, but with "$ s [0] →" instead, I don't get the methods of the Dummy class. This is due to the fact that in JavaDoc I just said that it is an array, but not a value type.

, , - JavaDoc, , JavaDoc, ?

+3
1

. . .

+2

Source: https://habr.com/ru/post/1750467/


All Articles