Home > Back-end >  PhpStorm, docblock with object shape
PhpStorm, docblock with object shape

Time:08-28

I want to define object shape for autocompletion in PhpStorm.

for example:

$myobject = json_decode("{id:1, price:123.99}");

for arrays exists docblock:

/**
 * @var array{id: int, price: float}
 */
$myArray = json_decode($jsonString, true);

and when I type:

$myArray[''] 

IDE autocompletes it to id | price

I want to do it in a similar way for objects:

/**
 * @var object|stdClass{id: int, price: float}
 */
$myObject = json_decode($jsonString, false);

and get autocomplete when I type

$myObject->

CodePudding user response:

Not supported by PhpStorm yet as fas as I'm aware.

https://youtrack.jetbrains.com/issue/WI-66396 -- watch this ticket (star/vote/comment) to get notified on any progress. Once implemented it will be coming as a part of Psalm plugin.

  • Related