PHP-CS-Fixer: [RFC] Inline docblock fixer

This RFC is for inline docblocks, since there are different ways to write them:

/** @var $someVar \SomeClass */
/* @var \SomeClass $someVar */

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 21 (18 by maintainers)

Commits related to this issue

Most upvoted comments

@rugk In your sample, the fixer follows PSR5 strictly and changes PHPDoc’s that doesn’t match the format. For now, if you don’t agree with the fixer you can disable/blacklist it when fixing.

For ref: https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#722-var

The @var tag MUST contain the name of the element it documents.

i.e. you must use the following occ. to PSR5 and the fixer

/** @var Something $newObject*/
$newObject = new Something;

Actually currently (speaking of v1.12.1 d33ee60) all /** inline PHPDOC comments are even converted to /*, which I don’t like. Similar things were already done in https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/2175, however in my case the PHPDOC comment is valid.

Here an example:

-/** @var Something */
+/* @var Something */
$newObject = new Something;

To me it makes sense to support fixing towards popular IDE’s, or to put it differently; no matter how good the PSR5 standard will be its usefulness will be determined by acceptance and implementation by tool builders. That aside, fixing PHPDoc’s OOTB 👍, for fixing comments I would like a config flag.

The bottom option is not actual doc. It’s just a comment.