As shown here in the proposal for phpdoc fig standard: https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#examples-12
Basically looks like this
/**
* Initializes this class with the given options.
*
* @param array $options {
* @var bool $required Whether this element is required
* @var string $label The display name for this element
* }
*/
public function __construct(array $options = array())
{
<...>
}
Would be really cool since PHP tends to use these option arrays all over the place in libraries!
btw, I think it would be really helpful to initially just parse and show it properly when hovering or typing the function out with the little intellisense above for the params. Support for doing $options['required'] and having intelephense know that it should be a bool is great, but I think probably also harder and not as important as just seeing the definition initially.
Alternate syntax that Psalm static checker uses: /** @return array<int, array{name: string, type: string, active: bool}> */ which is arguably nicer to look at and type.
This would be useful. I agree the Psalm syntax is nicer but the fig standard might have more clout. Either way this will require a proper phpdoc parser. Currently it is very simple and just uses regex to pick out the text and tags.
Hi. @bmewburn, if you did not decide on format yet, would you mind taking a look on the format deep-assoc-completion plugin uses in phpstorm?

Do you accept pull requests? I could write the phpdoc parser and add support for such format in your extension if you would like that ;-).
Upd.: I somewhat ported deep-assoc-completion to vscode. It's shipped as a separate extension, should work nicely together with intelephense.
@klesun, sorry for the late reply and thank you for your offer. For now I'd rather wait until some common standard emerges.
oh, ok (though I guess it will take quite some time...)
@bmewburn, there is no common standard for PHP; however, there is a common standard for JSDoc that works well for majority of usecases - see @typedef tag (http://usejsdoc.org/tags-typedef.html).
An example of a definition using jsdoc syntax
/**
/**
$person_array = array (
"493-11-1111"=> array("name"=>"John Doe", "address"=>array(city=>"Chicago"))},
"493-11-2222"=> array("name"=>"Jane Doe", "address"=>array(city=>"London"))},
);
The phpdoc proposed PSR no longer shows the format initially showed by @hworld.
Pslam has become quite popular now and it's format is pretty nice, so my vote goes to that :slightly_smiling_face:. I believe even phpstan is going to add / has added support for similar format.
Seems like psalm format is only sensible despite not being in PSR. JSDoc uses similar or the same format.
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#object-like-arrays
Any updates on this? Thanks!
I would appreciate this feature as well.
Most helpful comment
Alternate syntax that Psalm static checker uses:
/** @return array<int, array{name: string, type: string, active: bool}> */which is arguably nicer to look at and type.