首页 > 解决方案 > Phan 给出内置 JetBrains PhpStorm 注释的问题

问题描述

我对https://blog.jetbrains.com/phpstorm/2020/10/phpstorm-2020-3-eap-4/中描述的新 PhpStorm 内置注释有疑问

这是代码:

use JetBrains\PhpStorm\NoReturn;
#[NoReturn] public function __construct() {}

当我现在运行我的 Phan 静态分析器时,我收到以下错误:

PhanUndeclaredClassAttribute 对属性中未声明类 \JetBrains\PhpStorm\NoReturn 的引用

我怎样才能解决这个问题?我是否必须作曲家从 JetBrains 安装一些库才能在我的代码库中包含这些注释?

标签: phpphpstorm

解决方案


是的,请参阅https://github.com/JetBrains/phpstorm-attributes

这些属性在 PhpStorm 2020.3 及更高版本中可用。它们与 PhpStorm 捆绑在一起,因此您无需单独安装它们。

如果您正在使用其他静态分析工具并且不想遇到 Class not found 问题,那么您可能需要将属性包添加到 composer.json 作为开发依赖项:

composer require --dev jetbrains/phpstorm-attributes

推荐阅读