PhpStorm creates stubs of PHPDoc blocks on typing the opening tag /** and pressing EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter.
If this feature is applied to a method or a function, @param, @access, @static, @throws, and @abstract tags are created. In any other places PhpStorm adds an empty documentation stub.
If you need additional PHP-specific tags, PhpStorm provides code completion that suggests tag names that are relevant in the current context. If a certain tag has multiple values, the same code completion provides a list of available values.
In PHPDoc comments, PhpStorm supports the following formatting options in compliance with ZEND, PEAR, and other standards:
- Align parameter names
- Align tag comments
- Align key-value pairs
- Align consecutive assignments
PHPDoc comments in your source code are available for the Quick Documentation Lookup feature and open for review on pressing Ctrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+QCtrl+Q or Alt+Button2 ClickAlt+Button2 Click, Ctrl+Shift+Space or F2F1, Control J or Control Button2 ClickControl J or Control Button2 ClickAlt Button2 Click or F2.
On this page:
- Enabling creation of documentation comments
- Creating a PHPDoc block for a method or a function
- Creating tags in a PHPDoc comment block
- Inspecting PHPDoc comments
- Place the caret before the method or function declaration.
- Type the opening block comment /** and press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter.
- Describe the listed parameters and return values.
PhpStorm checks syntax in the comments and treats it according to the PHP Inspections settings.
- In a PHPDoc block, select the desired empty line and press Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceControl SpaceControl SpaceControl Space.
- Select the relevant tag from the suggestion list.
- If the entered tag has several values, press Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceControl SpaceControl SpaceControl Space and select the desired value from the suggestion list.
PhpStorm provides a set of predefined code inspections targeted at PHPDoc blocks. These inspections check whether classes, methods, functions, variables, and constants are supplied with a PHPDoc comment and whether the tags in the comment match the documented item.
To enable or disable an inspection:
- Choose Settings dialog box that opens, click Inspections. on the main menu, and in the
- On the Inspections page that opens, expand the PHPDoc node under the PHP node. The list of predefined inspections is displayed.
- To enable or disable an inspection, select or clear the check box next to it.
To have PhpStorm check that PHPDoc comments are provided for all code constructs of a certain type:
- Select the check box next to the Missing PHPDoc Comment inspection.
- In the Options area, select the check boxes next to the required code construct type: class, method, function, variable, or constant.
- To suppress reporting a Missing PHPDoc Comment error if a method or function does not contain any parameters and/or return values, select the Skip if empty.