[英]PHPStorm code completion for magic invoke static methods (Using curly braces syntax) [Pendent]
Using the following code, the code completion works fine! 使用以下代码,代码完成正常!
class FooClass
{
public function run(){}
}
/**
* @method static FooClass foo(bool $param1 = false)
*/
class Test
{
public static function __callStatic($name, $arguments)
{
//Implementation code ..
}
}
//Code completes fine for FooClass methods ..
Test::foo()->run();
But, its possible to IDE (PhpStorm) complete the code using the following php invocation method write style (Curly braces)? 但是,是否有可能使用以下php调用方法写样式(Curly花括号)来使IDE(PhpStorm)完成代码?
//Code NOT completes fine ..
Test::{"foo"}();
If so, how? 如果是这样,怎么办? Thanks for the help!
谢谢您的帮助!
PhpStorm doesn't support dynamic fields/methods. PhpStorm不支持动态字段/方法。 For a static tool, it's hard to track which field/method is actually accessed.
对于静态工具,很难跟踪实际访问哪个字段/方法。 Let's take a look at a more realistic example.
让我们看一个更现实的例子。
function foo($str) {
//Code NOT completes fine ..
Test::{$str}()->run();
}
This is how the dynamic invocation usually looks like. 这就是动态调用通常的样子。 In a real code,
$str
is typically a combination of an external input (eg from a database) and business logic. 在实际代码中,
$str
通常是外部输入(例如,来自数据库)和业务逻辑的组合。 Both are beyond the possibilities of a static analysis. 两者都超出了静态分析的可能性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.