PhpStorm 生成构造函数参数功能的快捷方式

Sex*_*yMF 3 phpstorm

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

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

Laz*_*One 5

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

  2. 在那里选择适当的选项——它将是Initialize fields

在此输入图像描述