-
-
Notifications
You must be signed in to change notification settings - Fork 103
Open
0 / 20 of 2 issues completedLabels
Description
Feature description or problem with existing feature
Currently, the following code autocompletes $myParam
key:
/**
* @param array{
* name: string,
* age: int
* } $myParam
*/
function test(array $myParam)
{
$myParam['nam'];
}
Unfortunately, adding inline comments breaks autocomplete:
/**
* @param array{
* name: string, // some other string here
* age: int // some integer over there
* } $myParam
*/
function test(array $myParam)
{
$myParam['nam'];
}
Describe the solution you'd like
It would be nice to be able to add inline comments (multiline comments are not possible because of PHP, see additional context) to keys, empowering documentation at a glance when having a look at the array shape. Ideally the inline comment could be displayed in the autocomplete window with the type, but this would be more of a "nice to have".
Additional context
- This follows an effort in Symfony to bring powerful autocomplete to configure the framework thanks to a
config()
function and array shapes: [FrameworkBundle] GenerateConfig
class symfony/symfony#58771 - A PR is being worked on to support this syntax is PHPStan and its PHPdoc Parser as well: support comments in array shape phpstan/phpdoc-parser#213
- Psalm supports the syntax: https://psalm.dev/r/e4b965c112
Ancyker, JasonTheAdams and azaryonok