为什么我在PhpStorm中通过此代码获得PHPDoc警告

Mat*_*oli 13 php warnings phpdoc phpstorm

我无法理解为什么PhpStorm会PHPDoc comment does not match function or method signature对此方法给出以下警告:

/**
 * Create a new instance of the class
 * @param string $classname Class to instantiate
 * @return object the instance
 * @throw FactoryException If the class is not instantiable
 */
private function newInstance($classname) {
    $reflectionClass = new \ReflectionClass($classname);
    if (! $reflectionClass->isInstantiable()) {
        throw new FactoryException("The class $classname is not instantiable.");
    }
    return new $classname;
}
Run Code Online (Sandbox Code Playgroud)

警告不是很具体,我已经尝试过几种方法,例如将返回类型更改为"对象","混合"或甚至"整数"(尝试),但它没有改变.这里有什么问题 ?

Met*_*rog 9

应该@throws不是@throw.

如果您只是键入/**函数或类var声明的行,它将自动为您插入一个基本的PHPDoc.这就是我注意到差异的方式.

在此输入图像描述

  • 新的EAP版本应该在今天晚些时候或明天晚些时候提供..但我不希望在那里修复它(至少基于相关的票证状态). (2认同)