I'm trying to find out how to properly document an array property in a class for phpdocumentor.
Ex:
<?php
class foo {
/**
* This holds something important
* @var string
*/
protected $junk;
/**
* This holds an important array of strings
* @var ???????
*/
protected $stuff = array();
// ...
}
?>
I couldn't find anything in the phpdoc manual about array properties.
/** @var array */
for your protected $stuff
is the proper syntax. The phpDocumentor manual page for @var shows "The datatype should be a valid PHP type (int, string, bool, etc),", and "array" is such a valid PHP type.
Some IDEs have also begun recognizing /** @var ElementType[] */
to indicate "this is an array, whose elements are all of type ElementType". This syntax will be available in an upcoming version of phpDocumentor.