为什么我在PhpStorm中得到一个PHPDoc警告这个代码

前端之家收集整理的这篇文章主要介绍了为什么我在PhpStorm中得到一个PHPDoc警告这个代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我不明白为什么PHPStorm给了我以下警告 PHPDoc注释与这种方法不匹配函数方法签名:
/**
 * 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;
}

警告并不是非常具体,我已经尝试过几种改变返回类型为“Object”,“mixed”甚至“int”(尝试)的东西,但没有改变.这里有什么问题?

应该是@throws不@throw.

如果您只是在函数或类var声明的行上键入/ **,它将为您自动插入基础PHPDoc.这就是我注意到的区别.

原文链接:https://www.f2er.com/php/131477.html

猜你在找的PHP相关文章