Proper way to denote array data type for phpDocumentor?
Both methods are technically correct, but this one is considered 'better' because it's more specific (int
and integer
are interchangeable):
@return int[]
Documented here:
http://www.phpdoc.org/docs/latest/guides/types.html
At the moment of writing this answer, these are the accepted ways of phpDocumentor (and probably other PHPDoc implementations) to denote an array:
unspecified, no definition of the contents of the represented array is given. Example:
@return array
specified containing a single type, the
Type
definition informs the reader of the type of each array element. Only oneType
is then expected as element for a given array. Example:@return int[]
Please note thatmixed
is also a single type and with this keyword it is possible to indicate that each array element contains any possible type.- 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)[]