Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpStorm 7 update docblock

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

like image 605
Steve Avatar asked Nov 07 '13 22:11

Steve


3 Answers

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.

like image 109
Maciej Sz Avatar answered Nov 01 '22 02:11

Maciej Sz


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/

like image 26
zainengineer Avatar answered Nov 01 '22 02:11

zainengineer


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.

like image 6
Amaynut Avatar answered Nov 01 '22 02:11

Amaynut