PhpStorm:可变成员可见性 class,基于接口和特征
PhpStorm: variable member visibility with class, based on interface and trait
我正在为 API 提供商特征进行简单设置。每个提供者都根据关于两个声明的 PHP 文档,根据特征和接口来声明功能和所需的功能。
我的 PhpStorm 清楚地索引了接口和特征函数,但没有索引变量成员。我已将它们声明为 public,受保护的或私有的——似乎没有任何作用。它们显然在 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"),但在索引后出现同样的情况。
有人知道吗?
我不知道有新的次要版本可用。更新到以下版本完全解决了我的问题。
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 注释版本 5.1
完全修复!感谢@LazyOne 为我指明了正确的方向。
参考问题@JetBrains:
https://youtrack.jetbrains.com/issue/WI-36285
我正在为 API 提供商特征进行简单设置。每个提供者都根据关于两个声明的 PHP 文档,根据特征和接口来声明功能和所需的功能。
我的 PhpStorm 清楚地索引了接口和特征函数,但没有索引变量成员。我已将它们声明为 public,受保护的或私有的——似乎没有任何作用。它们显然在 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"),但在索引后出现同样的情况。
有人知道吗?
我不知道有新的次要版本可用。更新到以下版本完全解决了我的问题。
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 注释版本 5.1
完全修复!感谢@LazyOne 为我指明了正确的方向。
参考问题@JetBrains: https://youtrack.jetbrains.com/issue/WI-36285