#20 Generate Docblocks

To get PhpStorm to generate docblocks for you, place the cursor on a method and press Alt+Enter to invoke the intention actions menu then select Generate PHPDoc for function.

PhpStorm will add @param tags for every paramater and include their data types from provided type hints. It will also add an @return tag if a return type is specified or it sees the function returns non-null values.

If PhpStorm is unable to accurately detect the data type for a tag it will use a data type of mixed or omit the data type completely. In these situations remember to provide the data type yourself or correct it if it’s not accurate.

PhpStorm can also update the docblock for you if the function signature changes, just invoke the intention actions menu again and select Update PHPDoc Comment.

Further Reading

comments powered by Disqus