Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
like image 506
crmpicco Avatar asked Jan 29 '26 15:01

crmpicco


1 Answers

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

like image 90
Ponsjuh Avatar answered Jan 31 '26 03:01

Ponsjuh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!