Rector PHP:无法在校长规则中添加数组索引
使用Rector,我正在尝试转换以下内容。
$integer = some_made_up_function_call($parm1, $parm2);
其中:
$integer = $parm1->made_up_method_call($parm2)['hard_coded_index'];
我的问题是['hard_coded_index']
最后。我不知道如何做到这一点。到目前为止,我所拥有的。
public function refactor(Node $node): ?Node
{
if (! $this->isName($node->name, 'some_made_up_function_call')) {
return null;
}
$firstParameter = new Node\Expr\Variable($node->args[0]->value->name);
return new Node\Expr\MethodCall(
$firstParameter,
'made_up_method_call',
[$node->args[1]]
);
}
Using Rector, I'm trying to convert the following.
$integer = some_made_up_function_call($parm1, $parm2);
Into this:
$integer = $parm1->made_up_method_call($parm2)['hard_coded_index'];
My issue is with the ['hard_coded_index']
at the end. I can’t figure out how to accomplish that. What I have so far is.
public function refactor(Node $node): ?Node
{
if (! $this->isName($node->name, 'some_made_up_function_call')) {
return null;
}
$firstParameter = new Node\Expr\Variable($node->args[0]->value->name);
return new Node\Expr\MethodCall(
$firstParameter,
'made_up_method_call',
[$node->args[1]]
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我想出了...
All right, I figured it out...