3

Can anyone advise where in the PSR standards docs it documents that there should be nothing after the variable type in class member variables?

I used PHP CodeStyle Fixer by doing the following: php-cs-fixer fix MyConsoleCommand.php

...and it removed the variable from the docblock. I have been doing this for some time now and I believed this was correct and standards-compliant.

Can anyone confirm?

     /**
-     * @var SiteManager $siteManager
+     * @var SiteManager
      */
     private $siteManager;

     /**
-     * @var Registry $doctrine
+     * @var Registry
      */
     private $doctrine;
crmpicco
  • 16,605
  • 26
  • 134
  • 210
  • 4
    AFAIK PSR doesn't say anything about this... But it *is* redundant, so why keep it? – deceze Jul 25 '16 at 08:29
  • 1
    Most (if not all) rules for phpdoc are tagged *symfony* so I guess they come from that Framework style guide and not PSR. That's particularly true here: **phpdoc_var_without_name [symfony]** – Álvaro González Jul 25 '16 at 08:34

1 Answers1

5

By default all the levels are on and this particulair behaviour comes from the sympfony standard

phpdoc_var_without_name [symfony] @var and @type annotations should not contain the variable name.

see https://github.com/FriendsOfPHP/PHP-CS-Fixer and search for "phpdoc_var_without_name"

if you don't want to use the Symfony standard do

php php-cs-fixer.phar fix MyConsoleCommand.php --level=psr2

hope it helps

crmpicco
  • 16,605
  • 26
  • 134
  • 210
Ponsjuh
  • 468
  • 3
  • 13