在PSR标准中,哪里规定在类型声明之后不包含变量名


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

有人能告诉PSR标准文档中的哪里,它记录了类成员变量中变量类型之后不应该有任何内容吗?

我通过以下操作使用了PHP CodeStyle Fixer:php-cs-fixer fix MyConsoleCommand.php

并从文档块中删除了该变量。我这样做已经有一段时间了,我相信这是正确的,符合标准。

有人能证实吗?

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

默认情况下,所有级别都处于打开状态,这种特殊行为来自症状标准

phpdoc_var_without_name[symfony]@var和@type注释不应包含变量名。

参见https://github.com/FriendsOfPHP/PHP-CS-Fixer并搜索"phpdoc_var_without_name"

如果你不想使用Symfony标准做

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

希望它能帮助