Posts

Showing posts with the label Phpdoc

Best Way To Document Array Options In PHPDoc?

Image
Answer : A bit too late to the party but this is how I do it instead: /** * Class constructor. * * @param array $params Array containing the necessary params. * $params = [ * 'hostname' => (string) DB hostname. Required. * 'databaseName' => (string) DB name. Required. * 'username' => (string) DB username. Required. * 'password' => (string) DB password. Required. * 'port' => (int) DB port. Default: 1433. * 'sublevel' => [ * 'key' => (\stdClass) Value description. * ] * ] */ public function __construct(array $params){} Think it's quite clean and easy to understand what $params should be. I wrote a plugin for phpstorm that allows specifying keys like this: (basically just a slightly stricter version of @siannone's format) /** * @param array $arr = [ * 'fields' => [ // Defines the feilds t...