2016-07-20 8 views
1

私はPHP 7プロジェクトでプロジェクトに取り組んでいます。PhpStorm 10.0.2PhpStormが「引数型が一致しません」というエラーを報告するのはなぜですか?

私はスカラー型のためのヒンティング型を持つ関数パラメータのためたPHPDoc @paramを宣言するたびに(stringintを、...)私はこの警告を得る:

引数の型が

と一致していません

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は文句いくつかのサンプルコードです2つの強く型付けされた文字列パラメータを持つコンストラクタたPHPDocにするために疑わしい-hintを「引数の型が一致しません」の表示PhpStormのスクリーンショット:私は何か間違ったことをやっている場合

Screenshot of PhpStorm displaying an "Argument type does not match" hint for a string function parameter that has type hinting

誰もが知っていますかこれがPhpStormのバグだとしたら?

+0

私は過去数年間、毎日PHPStormを使用しています。残念ながら、リリース間でこのような不愉快なバグが詰まっています。 – Marty

+0

@Martyなぜあなたはそれを使い続けますか?なぜあなたは変わっていないのですか? – BeetleJuice

+0

@BeetleJuice何に? PHPDocのサポートは他にありません。 – Marty

答えて

4

PHPStormのバージョンは、PHP 7の7日後にリリースされたので、言語の新機能(スカラー型ヒントを含む)のサポートはそれほど大きくありません。あなたはIDEのバグを経験しています。あなたの問題はprobably this oneです。これはPHPStorm 10.0.3で固定されています。

関連する問題