Reputation: 2154
I have a list of objects which I retrieve in the following way:
list($var1, $var2, $var3) = $helper->getStuff();
except longer.
Now, all of these variables are of the same class, Foo
, and I want to annotate them so that the IDE (PHPStorm) realizes what I'm doing.
Normally, getting one variable at a time, I would go
/**@var Foo $var1 */
$var1 = ...;
/**@var Foo $var2 */
$var2 = ...;
etc. But how can I accomplish this, with the list($var1, $var2, $var3) = ...;
way of getting them?
Ideally, it would be something like
/**@var Foo $var1, $var2, $var3 */
so that I could consolidate them into one line. And yes, I've tried that, both comma-separated and space-separated.
Upvotes: 3
Views: 484
Reputation: 26375
You can place them all in a single block above it. For example:
/**
* @var Foo $var1
* @var Foo $var2
* @var Foo $var3
*/
list($var1, $var2, $var3) = $helper->getStuff();
You can wedge them all into one line if you use separate blocks, like:
/**@var Foo $var1*/ /**@var Foo $var2*/ /**@var Foo $var3*/
list($var1, $var2, $var3) = $helper->getStuff();
but I suspect that's not the concise readability you're after.
Upvotes: 4