加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 17:36:04 所属栏目:PHP教程 来源:网络整理
导读:我不明白为什么PhpStorm给了我以下警告 PHPDoc注释与这种方法不匹配函数或方法签名: /** * Create a new instance of the class * @param string $classname Class to instantiate * @return object the instance * @throw FactoryException If the class i
我不明白为什么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.这就是我注意到的区别.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读