Search code examples
phpdocumentationphpdoc

How should I document allowable array param values in php


Often I am passing an array as a constructor parameter. How should I document the allowable values? I have tried a few styles but they look a bit of a mess in phpdoc.


Solution

  • There really is no "official" phpdoc way for documenting hashed arrays but here's one way:

    /**
     * @param array $options hash of standard options for this class:
     *    int id the id of whatever object
     *    string name name of whoever it is
     *    array sub_option hash of sub options:
     *        int num number description for this index
     *    bool is_good should we do this or not?
     */
     function __construct( $options ){
     }