Reputation: 11165
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;
....
}
}
Upvotes: 3
Views: 2778
Reputation: 1
You can initialize and create __construct method by shortcut
Place your cursor where you want to create __construct method then press ALT + Insert Select constructor and choose your propertise
Upvotes: 0
Reputation: 165278
Place caret on __construct
or inside its' parameters .. and invoke Quick Fix menu (Alt + Enter or via light bulb icon).
Choose appropriate option there -- it will be Initialize fields
Upvotes: 5
Reputation: 15676
Yes, place cursor on $model2
, then press Alt+Enter and choose option Initialize fields
.
It will create a private field in your class (if it doesn't exists yet), and assign it inside constructor.
Upvotes: 2