PHPDoc comments
For documentation comments, IntelliJ IDEA provides completion that is enabled by default. IntelliJ IDEA creates stubs of PHPDoc blocks when you type the /**
opening tag and press Enter, or press AltInsert and appoint the code construct (a class, a method, a function, and so on) to document. Depending on your choice, IntelliJ IDEA will create the required tags or add an empty documentation stub.
If you need additional PHP-specific tags, IntelliJ IDEA provides code completion that suggests the tag names that are relevant in the current context. If a certain tag has multiple values, code completion provides a list of available values.
In PHPDoc comments, IntelliJ IDEA supports formatting options in compliance with the ZEND, PEAR, and other coding standards.
PHPDoc comments in your source code are available for Quick Documentation Lookup, which helps you get quick information for any documented symbol. You can open them for review in the Documentation tool window by pressing Ctrl0Q.
This functionality relies on the PHP plugin, which you need to install and enable.
note
The PHP plugin is available only in IntelliJ IDEA Ultimate.
Press CtrlAlt0S to open the IDE settings and select Plugins.
Open the Marketplace tab, find the PHP plugin, and click Install (restart the IDE if prompted).
Press CtrlAlt0S to open the IDE settings and select Editor | General | Smart Keys.
In the Enter section, select or clear Insert documentation comment stub checkbox.
To invoke generation of a PHPDoc block, do one of the following:
Place the caret before the required code construct (class, method, function, and so on), type the opening block comment
/**
, and press Enter.In the editor context menu, select Generate | Generate PHPDoc blocks and choose the code construct to generate PHPDoc comments for.
Press AltInsert, then select Generate PHPDoc blocks, and choose the code construct to generate PHPDoc comments for.
GifIntelliJ IDEA analyzes the appointed code construct, extracts the data for parameters, return values, variables, or fields where possible, and on this basis generates a stub of a documentation block.
Describe the listed parameters and return values where necessary. IntelliJ IDEA checks and treats syntax in comments according to the code inspection settings.
IntelliJ IDEA analyzes the appointed code construct, extracts the data for parameters, return values, variables, or fields where possible, and on this basis generates a stub of a documentation block. If necessary, you can fill in the missing information.
In a PHPDoc block, select the desired empty line and press CtrlSpace.
Select the relevant tag from the suggestion list.
If the entered tag has several values, press CtrlSpace and select the desired value from the suggestion list.
You can configure the appearance of PHPDoc comments, the presentation of class names, and the default tags sorting order. Note that the tag for properties is no longer configurable, the default @var tag is inserted automatically. See https://github.com/phpDocumentor/fig-standards/pull/55 for details.
In the Settings dialog (CtrlAlt0S), go to Editor | Code Style | PHP.
Switch to the PHPDoc tab an configure the desired appearance options by selecting or clearing the checkboxes.
Specify how you want IntelliJ IDEA to present class names for properties, function parameters, return and throws values, and so on, by selecting or clearing the Use fully-qualified class names checkbox.
If necessary, define how the generated PHPDoc tags should be sorted by selecting the Sort PHPDoc tags checkbox.
Use
and
to add or remove the PHPDoc tag entries from the list.
Use
and
to arrange the PHPDoc tag entries order.
note
The PHPDoc tags that are not added to the list are generated below the listed ones.
IntelliJ IDEA allows you to render Javadocs in the editor. Rendered comments are easier to read, and they don't overload your code with extra tags.
Click in the gutter next to the necessary documentation comment (or press CtrlAlt0Q) to toggle the rendered view; click
to edit the comment.


Rendered Javadocs allow you to click links to go to the referenced web pages, or view quick documentation for the referenced topics.
To change the font size, right-click a Javadoc in the editor and select Adjust Font Size from the context menu. Note that the rendered comments use the same font size as the quick documentation popup.
You can configure the IDE to always render Javadocs in the editor.
Right-click the icon in the gutter (
or
) and enable the Render All option.
Alternatively, in the Settings dialog CtrlAlt0S, select Editor | General | Appearance and enable the Render documentation comments option.
To edit rendered Javadocs, click the icon in the gutter next to the comment.
IntelliJ IDEA 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.
In the Settings dialog (CtrlAlt0S), select Editor | Inspections.
On the Inspections page that opens, expand the PHPDoc node under PHP.
In the list of predefined inspections that opens, enable or disable an inspection by selecting or clearing the checkbox next to it.
Enable the Missing PHPDoc Comment inspection.
In the Options area, select the checkboxes next to the required element 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 or return values, select the Ignore PHPDoc without @param/@return checkbox.
Thanks for your feedback!