0

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.

2
  • I think it might be better to explicitly define what parameters you want to receive as opposed to passing an array. Commented Sep 17, 2012 at 0:35
  • If you've got lots of params, consider building a separate object(s). Commented Sep 17, 2012 at 1:42

1 Answer 1

2

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 ){
 }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.