30

Is there a way to ask phpStorm to update the contents of a docblock? eg if I have the following code

//-------------------------------------------------------------------------
/**
 * @param string $url
 * @return $this
 */
public function setBaseUrl($url)
{
    $this->baseUrl = $url;
    return $this;
}

and add another parameter

//-------------------------------------------------------------------------
/**
 * @param string $url
 * @return $this
 */
public function setBaseUrl($url, $anotherParameter)
{
    $this->baseUrl = $url;
    return $this;
}

is there a way to ask phpStorm to create the @param $anotherParameter in my docblock? (in a single keystroke or by menu selection)?

3 Answers 3

64

Alt+Enter (Show Intention Actions) on the comment, then Enter again.

This is configurable via [Settings > Keymap] then [Other > Show Intention Actions]

Alternatively you can do the same with mouse if you click on the comment, and then on the yellow bulb that shows up.

3
  • 2
    that didn't work for me (mac OSX). Alt Enter (or any meta-Enter combo) does nothing but add a newline. There is no lightbulb to click on. Have i misconfigured something?
    – Steve
    Nov 9, 2013 at 7:15
  • You probably did, or maybe the shortcuts are so very different. It works fine for me. Try to set the shortcut in settings. I'll add it th the answer. Also take a look at this official blog post: blog.jetbrains.com/webide/2011/05/phpdoc-inspections
    – Maciej Sz
    Nov 9, 2013 at 8:36
  • 4
    figured it out: somehow the phpDoc inspection was disabled in the project (I'd been looking at the global/default settings). Turned those on and it all started to work as you said. thanks for your help (and sorry for the dumb question)
    – Steve
    Nov 10, 2013 at 23:45
10

I used to press Control-Enter inside the dock block and it used to update. And for some reason it stopped working.

Finally I figured that PHPStorm has changed its behavior.

Now you need to put the cursor on the missing variable name and then press Control-Enter. It will update the dock block.

And of course make sure that phpDoc inspection is enabled as Steve has mentioned in the comment. Also have a read of http://blog.jetbrains.com/webide/2011/05/phpdoc-inspections/

1
  • 1
    this should be the answer, as well, at least, by commenting this answer will look like having higher impact, what is true
    – FantomX1
    Mar 15, 2018 at 15:12
6

In the new version of PHPStorm 2016.x you need to place your cursor in the missing variable name and press alt + enter then hit again enter to add the missing param to the doc block. If you need to remove a parameter you need to go to the extra param and press the same key strokes.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.