简体   繁体   中英

Phan giving problems with built-in JetBrains PhpStorm annotations

I have a problem with the new PhpStorm built-in annotations described in https://blog.jetbrains.com/phpstorm/2020/10/phpstorm-2020-3-eap-4/

This is the code:

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

When I now run my Phan static analyser I get the following errors:

PhanUndeclaredClassAttribute Reference to undeclared class \JetBrains\PhpStorm\NoReturn in an attribute

How can I fix this? Do I have to composer install some lib from JetBrains to have these annotations in my code base?

Yes, see https://github.com/JetBrains/phpstorm-attributes

The attributes are available in PhpStorm 2020.3 and later. They are bundled with PhpStorm so you don't need to install them separately.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM