Reputation: 5
There are few classes:
abstract class AbstractBase
{
protected Service1 $service1;
public function __construct(Serivice1 $s)
{
$this->service1 = $s;
}
}
class Child extends AbstractBase
{
private Service2 $service2;
}
If I press Alt + Insert
(for child class) and select Constructor
, PhpStorm will show me only properties from child class. How to generate constructor with both: child and parent class, like this?
public function __construct(Service1 $service1, Service2 $service2)
{
parent::__construct($service1);
$this->service2 = $service2;
}
Upvotes: 0
Views: 1359
Reputation: 165288
How to generate constructor with both: child and parent class
Currently it's not possible.
https://youtrack.jetbrains.com/issue/WI-40676 -- watch this ticket (star/vote/comment) to get notified on any progress.
The best I can suggest right now is this:
Code | Generate...
menu (Alt + Insert on Windows keymap) use Override Methods...
option instead.__construct()
. It will create the same method as parent class has.private Service2 $service2;
line, place it on $service2
, invoke Alt + Enter menu and then choose Add constructor parameters
entry.Upvotes: 1