PhpStorm生成构造函数参数功能的快捷方式 [英] PhpStorm shortcut to generate constructor params functionality

查看:712
本文介绍了PhpStorm生成构造函数参数功能的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PhpStorm中是否有快捷方式来为$model2生成与$model1相同的代码?

Is there a shortcut in PhpStorm to generate code for $model2 same as $model1?

class Test{    
    private $model1;
    public function __construct(string $model1, $model2)
    {
       $this->model1 = $model1;
       ....          
    }
}

推荐答案

  1. 将插入号放置在__construct或其参数内..并调用快速修复"菜单( Alt + Enter 或通过灯泡图标).

  1. Place caret on __construct or inside its' parameters .. and invoke Quick Fix menu (Alt + Enter or via light bulb icon).

在此处选择适当的选项-将为Initialize fields

Choose appropriate option there -- it will be Initialize fields

这篇关于PhpStorm生成构造函数参数功能的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆