0

If you have a function that takes an array as one of it's parameters, how would one specify the keys for the array?

I was thinking something to represent:

array(
    'name' => 'foo'
    'email' => '[email protected]'
);

could be

@param array $user [name, email]

A solution that works in PHPStorm would be great!

Bonus: how can you specify if the key is optional?

5
  • what do you mean "how would one specify the keys for the array?" ? What do you want to achieve with that? Commented Apr 29, 2016 at 15:34
  • updated question for clarity @oli Commented Apr 29, 2016 at 15:37
  • Thanks, but what do you want to achieve with Phpstorm, you want the editor marks you the index as invalid if its not specified in the doc? The part "works in PHPStorm" seems strange to me. This editor let you use any index without checking it. You want more strict behaviour? Commented Apr 29, 2016 at 15:44
  • @oli yes, pretty much Commented Apr 29, 2016 at 15:47
  • 1
    There is no strictness check for array keys. For code completion help you can install Options completion plugin -- it uses phpDocumentor's hash description. Commented Apr 29, 2016 at 16:11

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.