0

Is there a shortcut for PhpStorm (or other JetBrains IDE, they're likely to be the same) that will automagically fill in default parameter values for method calls?

IE, I'm typing in:

$form->generateSelectBox("weekly_snapshot_id", "Weekly snapshot", ...loads of default values here..., "value I actually wanted to set");

and I'd actually just like to type:

$form->generateSelectBox("weekly_snapshot_id", "Weekly snapshot");

put the cursor inside the argument list and hit CTRL + WHATEVS and get ...loads of default values here... automagically completed for me.

Haven't found anything in the dox, google or previous questions that might do this, some tantalising hints about IntelliJ plugins that did this out there but nothing for PhpStorm specifically.

Screenshot as requested: (I select 'params' not cust_id)

Screenshot as requested

1 Answer 1

1

You'll be able to do that via Ctrl+Space suggestion list starting PhpStorm version 2019.2: https://youtrack.jetbrains.com/issue/WI-45683

Sign up to request clarification or add additional context in comments.

5 Comments

Have now got 2019.2 but still can't get this to happen with CTRL + SPACE or TAB inside the function arg list - all I can get it do so is enter a value for any arguments without default values, not fill in the actual default values as literals etc. Any hints please?
Would it be possible to attach screenshots that would illustrate the problem here or at youtrack.jetbrains.com/issue/WI-45683?
Thanks for picking this up so quickly. My method definition is this: public function getCustomerPoliteName($cust_id, $type = "billing", $fullName = false) { and I'm using it like this: $cust_name = $ghb->getCustomerPoliteName(); I put my cursor in the brackets and hit CTRL + SPACE and get a dropdown with 'params' at the top. I click params and get this: $cust_name = $ghb->getCustomerPoliteName($cust_id); where '$cust_id' has a red outline. I was hoping to get: $cust_name = $ghb->getCustomerPoliteName($cust_id, "billing", false); Thanks.
Looks like a bug. Interestingly it works in simple cases like function + its call: function getCustomerPoliteName($cust_id, $type = "billing", $fullName = false){} getCustomerPoliteName( ); But this doesn't work when calling a new instance. I'll check that in a ticket
yup, that's a bug. Submitted: youtrack.jetbrains.com/issue/WI-47702

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.