我正在使用API提供程序特征的简单设置。根据相应声明的PHP文档,每个提供程序都使用特征和接口,声明功能和所需的功能。
我的PhpStorm清楚地索引接口和traits函数,但不索引变量成员。我宣称它们是公开的,受保护的或私人的 - 似乎没有任何效果。他们显然在PHP7环境中工作,但我的PhpStorm认为我已经动态地声明了它们。
基本上,这是我的设置。
interface ProviderInterface
{
const TYPE_ELECTRICITY = 'electricity';
const TYPE_GAS = 'gas';
/**
* @param ContainerInterface $container
*
* @return void
*/
function setContainer(ContainerInterface $container);
/**
* @return Client|\SoapClient
*/
function client();
}
trait ProviderTrait
{
/**
* @var string
*/
private $endpoint = '';
public function setContainer($container) {
/** void for demo purposes */
}
}
class Provider implements ProviderInterface
{
use ProviderTrait;
/**
* @var string
*/
private $username;
/**
* @var string
*/
private $password;
/**
* constructor.
*
* @param ContainerInterface $container
*/
final public function __construct(ContainerInterface $container)
{
$this->setContainer($container);
/**
* While $username and $password are declared within this class, the $endpoint is declared in the ProviderTrait. PHP works fine. PhpStorm ignores it and says it is declared "dynamically".
*/
$this->endpoint = $this->container->getParameter('api.endpoint');
$this->username = $this->container->getParameter('api.username');
$this->password = $this->container->getParameter('api.password');
}
我已经尝试清除缓存(“Invalidate& Restart”)但在索引之后也是如此。
有人有个主意吗?
答案 0 :(得分:2)
我不知道有一个新的次要版本可用。更新到以下版本完全解决了我的问题。
PhpStorm 2017.2.2
Build #PS-172.3968.35, built on August 31, 2017
JRE: 1.8.0_152-release-915-b11 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Symfony插件版本0.14.151 PHP Annotations版本5.1
完全修复!谢谢@LazyOne指出我正确的方向。
参考问题@ JetBrains : https://youtrack.jetbrains.com/issue/WI-36285