I'm using short syntax to define member variables of a class so instead of
private $a;
private $b;
private $c;
I use
private
$a,
$b,
$c;
Now I use PHPDoc to tell the IDE of the type of each member like so:
/** @var classA */
private $a;
/** @var classB */
private $b;
/** @var classC */
private $c;
However this doesn't work with the short syntax:
private
/** @var classA */
$a,
/** @var classB */
$b,
/** @var classC */
$c;
What am I doing wrong?
Not the answer you want to hear, but that you can't do. PHPDoc isn't as smart as you want it to be, though life on earth would be almost impossible without it.
Besides, things normally start to get messy when people stop following PSR conventions, like declaring multiple properties per statement. So, don't reinvent the wheel, if you don't like the generally accepted way – stick with it and you'll get over this soon enough ;)
Srsly…
Actually, phpDocumentor 2.x does support the compound declaration, though using one docblock rather than many -- http://phpdoc.org/docs/latest/references/phpdoc/tags/var.html
Note that if you don't get the doc results you expect, it may be a bug (like the one shown here -- phpDoc @var for compound statement isn't displayed correctly).
If you're looking at similar types; for example:
/** @var string */
private $stringVariable;
/** @var string */
private $stringVariable2;
/** @var string */
private $anotherVariable;
/** @var string */
private $andMoreStringTypes;
you can ofcourse use /** @var string */
for every rule - but you can also use DocBlock templates, like so:
/**#@+
* @var string
*/
private $stringVariable;
private $stringVariable2;
private $anotherVariable;
private $andMoreStringTypes;
/**#@-*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With