phpstrom 配置getter和setter
先看一段代码
protected $mddid; /** * @return mixed */ public function getMddid() { return $this->mddid; } /** * @return string */ public static function fieldMddid() { return "mddid"; } /** * @param mixed $mddid * @return Mdd */ public function setMddid($mddid) { $this->mddid = $mddid; return $this; }
这个是如何配置的呢?
phpstrom -> preferences -> editor -> file and Code Templates -> code
Getter模板
/** * @return ${TYPE_HINT} */ public ${STATIC} function ${GET_OR_IS}${NAME}()#if(${RETURN_TYPE}): ${RETURN_TYPE}#else#end { #if (${STATIC} == "static") return self::$${FIELD_NAME}; #else return $this->${FIELD_NAME}; #end } /** * @return string */ public static function field${NAME}()#if(${RETURN_TYPE}): string#else#end { return "${FIELD_NAME}"; }
Setter模板
/** * @param ${TYPE_HINT} $${PARAM_NAME} * @return ${CLASS_NAME} */ public ${STATIC} function set${NAME}(#if (${SCALAR_TYPE_HINT})${SCALAR_TYPE_HINT} #else#end$${PARAM_NAME}) { #if (${STATIC} == "static") self::$${FIELD_NAME} = $${PARAM_NAME}; #else $this->${FIELD_NAME} = $${PARAM_NAME}; return $this; #end }
千里之行,始于足下。改变现在,就是改变未来。改变未来,从现在开始。