How to document an array of [type]?

From the documentation of phpDocumentor

The value represented by Type can be an array. The type MUST be defined following the format of one of the following options:

  1. unspecified, no definition of the contents of the represented array is given. Example: @return array

  2. specified containing a single type, the Type definition informs the reader of the type of each array element. Only one Type is then expected as element for a given array.

    Example: @return int[]

    Please note that mixed is also a single type and with this keyword it is possible to indicate that each array element contains any possible type.

  3. specified containing multiple types, the Type definition informs the reader of the type of each array element. Each element can be of any of the given types. Example: @return (int|string)[]

    Note
    many IDEs probably do not support this notation yet.


In PHPDoc you can do the following for type hinting array members:

@var array<\My\Folder\ClassName>

UPDATE

You can also explicitly declare the key for associative arrays as follows:

@var array<string, \My\Folder\ClassName>

And according to the answer posted here you can even explicitly declare the keys in case you would like to do so like this:

/**
 * @return array[
 *  'controller' => string,
 *  'action' => string
 * ]
 */

Note: This is tested and works perfectly well in PHP storm:

enter image description here