Open iatanasov-frt opened 5 years ago
I would think a code action where the constructor signature is typed first would be easier, then automatically create a property and an assignment in the constructor body. Then there could be a single light bulb in the gutter next to the constructor that would add edits for all constructor args. Would this do?
Just a comment on how it looks in PhpStorm :-)
Note: PHP 8 comes with constructor property promotion...
hello, when you already have some property, you could autocomplete/suggest the constructor parameter name
Feature Constructor generator
Is it related a bug No
Describe feature behaviors Right now we have the
con
shortcut for generating generic constructor, but it would be way better if we have a way to generate better constructors faster.Most often when I create a class, I start by entering all fields with their types (in DocBlock for now, after php 7.4 we'd have a better way of doing this) and then I create a constructor and I start entering the very same fields again as parameters and then start assigning them in the body.
I'm thinking about having a "Add to constructor" command that is contextual for the class properties. That would save a lot of repetitive work.