为什么PhpStorm报告一个;参数类型不匹配";错误?

为什么PhpStorm报告一个;参数类型不匹配";错误?,php,phpstorm,phpdoc,php-7,type-hinting,Php,Phpstorm,Phpdoc,Php 7,Type Hinting,我正在使用PhpStorm 10.0.2进行一个php7项目 每当我为标量类型(string,int,…)具有类型暗示的函数参数声明PHPDoc@param),我都会收到以下警告: 参数类型不匹配 以下是PhpStorm抱怨的一些示例代码: class HostConfig { /** * @var string */ private $hostname; /** * @var string */ private $doma

我正在使用PhpStorm 10.0.2进行一个php7项目

每当我为标量类型(
string
int
,…)具有类型暗示的函数参数声明PHPDoc
@param
),我都会收到以下警告:

参数类型不匹配

以下是PhpStorm抱怨的一些示例代码:

class HostConfig
{
    /**
     * @var string
     */
    private $hostname;
    /**
     * @var string
     */
    private $domainname;

    /**
     * Creates a new instance of hte HostConfig model.
     *
     * @param string $hostname   A host name (e.g. "dev", "int", "feature-xy")
     * @param string $domainname A domain name (e.g. "example.com")
     *
     * @throws \InvalidArgumentException If the given $hostname is empty
     * @throws \InvalidArgumentException If the given $domainname is empty
     */
    public function __construct(string $hostname, string $domainname)
    {
        if (strlen(trim($hostname)) === 0) {
            throw new \InvalidArgumentException("The host name cannot be empty");
        }

        if (strlen(trim($domainname)) === 0) {
            throw new \InvalidArgumentException("The domain name cannot be empty");
        }

        $this->hostname = $hostname;
        $this->domainname = $domainname;
    }
}
以及PhpStorm的屏幕截图,其中显示有问题的“参数类型不匹配”-对于具有两个强类型字符串参数的构造函数,PHPDoc中的提示:


有人知道我是否做错了什么,或者这只是PhpStorm中的一个bug吗?

您的PhpStorm版本是在PHP7发布7天后发布的,因此它对该语言的新功能(包括标量类型暗示)的支持不是很好。您遇到了IDE错误。您的问题已通过

解决。在过去几年中,我每天都在使用PHPStorm,不幸的是,在不同版本之间,它充满了类似这样令人恼火的错误。@Marty,您为什么一直使用它?你为什么不换成什么?没有其他东西具有相同的PHPDoc支持。