phpStorm 7 update docblock
Asked Answered
N

3

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)?

Nimbus answered 7/11, 2013 at 22:49 Comment(0)
S
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.

Sutherland answered 7/11, 2013 at 23:7 Comment(3)
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?Nimbus
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-inspectionsSutherland
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)Nimbus
S
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/

Swee answered 13/11, 2015 at 5:29 Comment(1)
this should be the answer, as well, at least, by commenting this answer will look like having higher impact, what is trueRema
E
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.

Emend answered 28/3, 2017 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.