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.
Asked
Active
Viewed 759 times
0
-
I think it might be better to explicitly define what parameters you want to receive as opposed to passing an array. – Lix Sep 17 '12 at 00:35
-
If you've got lots of params, consider building a separate object(s). – Philip Whitehouse Sep 17 '12 at 01:42
1 Answers
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 ){
}

pogidude
- 76
- 1
- 1
- 8