bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.62k stars 94 forks source link

[Feature Request] Add property to constructor #651

Open iatanasov-frt opened 5 years ago

iatanasov-frt commented 5 years ago

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.

bmewburn commented 4 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?

boan-jfm commented 3 years ago

Just a comment on how it looks in PhpStorm :-)

image

Note: PHP 8 comes with constructor property promotion...

momala454 commented 2 years ago

hello, when you already have some property, you could autocomplete/suggest the constructor parameter name

image