Docblocker创建过程中的自动时间戳


Automatic timestamp during Docblocker creation?

有没有一种方法可以创建一个实时模板,通过在phpStorm:中按't'+TAB来给出当前时间戳

我想在创建DocBlocks时这样做,因为我喜欢跟踪代码中的变化,例如:

/**
 * This is the info for the doc.
 * User: sankalp
 * Date: 3/8/13   
 * Time: 10:58 AM <- I want the implementation here.
 * @author : sankalpsingha@gmail.com
 */
public function actionSomething(){
#some code here...
}

那么,有没有一种方法可以实现这一点呢?还是我必须使用查看手表并生成您自己的时间戳方法?

来源https://www.jetbrains.com/phpstorm/webhelp/file-templates.html:

文件模板是用Velocity模板语言(VTL)编写的。

显然VTL将时间预先定义为${TIME}

/**
 * Created by ${PRODUCT_NAME}.
 * User: ${USER}
 * Date: ${DATE}
 * Time: ${TIME}
 * To change this template use File | Settings | File Templates.
 */

有关Live模板,请参阅https://www.jetbrains.com/phpstorm/webhelp/live-templates.html

转到Live模板。创建一个名为t的新条目(或您想要的任何条目),并将$TIME$放入"模板文本"框中。将上下文设置为PHP。然后单击"编辑变量"并选择time()作为表达式。应用更改。下次点击选项卡-t时,它将插入当前时间。

然而,当您希望"跟踪代码中的更改"时,为什么不使用版本控制系统,如Git、Mercurial或SVN来跟踪更改呢。那么您根本不需要在DocBlock中花费时间。