PHPStorm Intellisense 无法识别 Class 中定义的常量
PHPStorm Intellisense Does Not Recognize Constants Defined in Class
有没有办法让 PhpStorm intellisense 获取这些动态定义的常量?鉴于下面的代码,PhpStorm 给出了 "Undefined constant SAMPLE_CONSTANT_THAT_WAS_DYNAMICALLY_DEFINED" 错误消息。
class ExampleConfiguration
{
private $configurationMapping;
...
public function DefineConfigConstants()
{
foreach ($this->configurationMapping as $key => $value)
define($key, $value);
}
}
class ExampleClass
{
public function Test()
{
print SAMPLE_CONSTANT_THAT_WAS_DYNAMICALLY_DEFINED;
}
}
可以在此处跟踪此问题:https://youtrack.jetbrains.com/issue/WI-11390,我正在寻找解决方法的建议。
IDE 需要了解这些常量,以免抱怨它们。这意味着它们必须以 "normal" 方式定义(实际值无关紧要,只要它们不用于 include/require 语句中的文件 names/paths)。
建议: 编写自定义脚本来创建这样的 myconstants.php
文件,它们将以正常方式定义(因为所有这些常量都由用户定义并存储在数据库中,你必须自己从数据库中获取它们).. 和 运行 在使用 PhpStorm 中的代码之前,这个脚本(更新生成的文件)。
有没有办法让 PhpStorm intellisense 获取这些动态定义的常量?鉴于下面的代码,PhpStorm 给出了 "Undefined constant SAMPLE_CONSTANT_THAT_WAS_DYNAMICALLY_DEFINED" 错误消息。
class ExampleConfiguration
{
private $configurationMapping;
...
public function DefineConfigConstants()
{
foreach ($this->configurationMapping as $key => $value)
define($key, $value);
}
}
class ExampleClass
{
public function Test()
{
print SAMPLE_CONSTANT_THAT_WAS_DYNAMICALLY_DEFINED;
}
}
可以在此处跟踪此问题:https://youtrack.jetbrains.com/issue/WI-11390,我正在寻找解决方法的建议。
IDE 需要了解这些常量,以免抱怨它们。这意味着它们必须以 "normal" 方式定义(实际值无关紧要,只要它们不用于 include/require 语句中的文件 names/paths)。
建议: 编写自定义脚本来创建这样的 myconstants.php
文件,它们将以正常方式定义(因为所有这些常量都由用户定义并存储在数据库中,你必须自己从数据库中获取它们).. 和 运行 在使用 PhpStorm 中的代码之前,这个脚本(更新生成的文件)。