Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short description for an array that has a described hash #30

Closed
ericandrewlewis opened this issue Sep 25, 2013 · 6 comments
Closed

Comments

@ericandrewlewis
Copy link

In the current PHPDoc standards, describing hashes does not afford for giving a short description to an array element in conjunction with the hash details.

Currently:

/**
 * Initializes this class with the given options.
 *
 * @param array $options {
 *     @type boolean $required Whether this element is required
 *     @type string  $label    The display name for this element
 * }
 */
public function __construct(array $options = array())
{
    <...>
}

As @mvriel has been working with us (the WordPress inline documentation team) on this, we've come up with the standard of putting the description inside the container block for describing hash elements, a la:

/**
 * Initializes this class with the given options.
 *
 * @param array $options {
 *     A description of this array.
 *
 *     @type boolean $required Whether this element is required
 *     @type string  $label    The display name for this element
 * }
 */
public function __construct(array $options = array())
{
    <...>
}
@mvriel
Copy link
Member

mvriel commented Sep 25, 2013

I have an update ready locally, just not found the time to finish it

@lisachenko
Copy link

👍 for array hash documentation

@donquixote
Copy link

To re-post the idea from the other thread:

/**
 * @param {
 *   type: string
 *   query: SelectInterface
 *     This is the query object.
 *   options: {
 *     color: string = 'blue'
 *   }
 * }[] $items
 *   And now a description about the entire param.
 * @param $options {
 *   # Or maybe put a description like this?
 *   color: string
 *     The colors of PDO.
 * }
 * @param string $label
 *   This param adds a label.
 */

I somehow don't like the @type all over the place. One @param should be enough for my taste, then the nested stuff should follow a simpler syntax. How exactly this looks like is a matter of discussion, I personally prefer sth around yml or json style.

@66Ton99
Copy link

66Ton99 commented May 23, 2014

Here you describe values but what about keys?

if I need return structured array like:

array(
    '2014-01-04' => '4 Jan 2014',
    ...
);

and I want to describe key and value?

@mvriel
Copy link
Member

mvriel commented May 24, 2014

@66Ton99 for the example you offer you would not need an elaborate piece because you don't have fixed keys; the following would suffice:

/** @type array<string, string> the key represents a date in the MySQL format (YYYY-MM-DD) where the value represents its counterpart in human-readable short notation (i.e. `4 Jan 2014`).

@mvriel
Copy link
Member

mvriel commented May 24, 2014

I am going to close this issue as it is basically a duplicate of #7; let's continue there

@mvriel mvriel closed this as completed May 24, 2014
ashnazg pushed a commit that referenced this issue Oct 2, 2018
* Rename Exception to ClientException

* typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants