22
votes

I search for a moment a way to change the name and mail used by PHPDoc in PhpStorm when you use the "autocomplete" by pressing Enter after typing /** just before a class or a function.

Example :

/**
 * Class DepartmentType
 *
 * @author Foo Bar <[email protected]>
 */
class Foo
{

Because, this name and this mail is not the name and mail configure for the git I use in my project. I don't find any place to change this defaults values...

Anyone have an idea ?

5

5 Answers

40
votes

Preferences > Editor > File and Code Templates > Includes tab > PHP Class Doc Comment

/**
 * Class ${NAME}
#if (${NAMESPACE}) * @package ${NAMESPACE}
#end
 * @author Foo Bar <[email protected]>
 */

I edited @Mahmoud Zalt's answer, which is basically right, but the edit was rejected, so here you go. @Mahmoud Zalt's answer will only work if you have a namespace in the class, which is what the if/end logic is looking for.

10
votes

Create custom template variables and define their values right in the include template using the #set VTL directive. For example, if you want to your full name inserted in the file header instead of your login name defined through the ${USER}, write the following construct:

#set( $MyName = "John Smith" )

.Ref: https://www.jetbrains.com/help/phpstorm/2017.1/creating-and-editing-file-templates.html

My Solution:

Go to : Preferences > Editor > File and Code Templates > Includes tab > PHP Class Doc Comment

/**
 #set( $USER = "Javier Solis Flores ( @JavierTwiteando )" )
 * Created by ${PRODUCT_NAME}.
 * User: ${USER}
 * Date: ${DATE}
 * Time: ${TIME}
 */
4
votes

Go to: preferences > Editor > File and Code Templates > [Includes] > PHP Class Doc Comment.

example:

/**
 * Class ${NAME}
 * 
 * @category 
#if (${NAMESPACE}) * @package ${NAMESPACE}
#end
 * @author John Doe <[email protected]>
 */
3
votes

If you are using PhpStorm 2017.1:

File > Settings > Editor > File and Code Templates > [Includes] > PHP File Header

Here you can edit the comment.

1
votes

In PHPSTORM 2017.1 you can change it at

File -> Settings -> File and Code Templates -> Includes tab -> PHP File Header