Phan 给出了内置 JetBrains PhpStorm 注释的问题 [英] Phan giving problems with built-in JetBrains PhpStorm annotations
问题描述
我对 https://blog.jetbrains.com/phpstorm/2020/10/phpstorm-2020-3-eap-4/
这是代码:
use JetBrains\PhpStorm\NoReturn;
#[NoReturn] public function __construct() {}
现在运行 Phan 静态分析器时,出现以下错误:
When I now run my Phan static analyser I get the following errors:
PhanUndeclaredClassAttribute 对属性中未声明类 \JetBrains\PhpStorm\NoReturn 的引用
PhanUndeclaredClassAttribute Reference to undeclared class \JetBrains\PhpStorm\NoReturn in an attribute
我该如何解决这个问题?我是否必须从 JetBrains 安装一些库才能在我的代码库中添加这些注释?
How can I fix this? Do I have to composer install some lib from JetBrains to have these annotations in my code base?
推荐答案
是的,请参阅 https://github.com/JetBrains/phpstorm-attributes
属性在 PhpStorm 2020.3 及更高版本中可用.它们与 PhpStorm 捆绑在一起,因此您无需单独安装它们.
The attributes are available in PhpStorm 2020.3 and later. They are bundled with PhpStorm so you don’t need to install them separately.
如果您正在使用其他静态分析工具并且不想遇到 Class not found 问题,那么您可能需要将属性包作为开发依赖项添加到您的 composer.json 中:
If you are using other static analysis tools and don’t want to get Class not found issues, then you might want to add the attributes package to your composer.json as a dev dependency:
composer require --dev jetbrains/phpstorm-attributes
这篇关于Phan 给出了内置 JetBrains PhpStorm 注释的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!