crmpicco crmpicco - 1 year ago 79
PHP Question

Where in the PSR standards does it say to not have the variable name after the type declaration?

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;

Answer Source

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 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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download