make getter and setter even better

This commit is contained in:
chrisyue 2012-12-04 00:18:40 +08:00
parent 211b082845
commit 12f2641e9d

View File

@ -39,23 +39,30 @@ snippet m
${7} ${7}
} }
# setter method # setter method
# I think vim's functions will not be called at the snipMate's runtime
# but `compile` time
# so `tolower` here won't work
# but it would be wonderful if we could make the property and parameter to lower case
snippet sm snippet sm
${1:public} function set${2:Foo}(${3:$2 }$${4:`tolower('$2')`}) /**
* Sets the value of ${1:foo}
*
* @param ${2:$1} $$1 ${3:description}
*
* @return ${4:`Filename()`}
*/
${5:public} function set${6:$2}(${7:$2 }$$1)
{ {
$this->${5:$4} = $$4; $this->${8:$1} = $$1;
${6}
return $this; return $this;
} }${9}
# getter method # getter method
snippet gm snippet gm
${1:public} function get${2:Foo}() /**
* Gets the value of ${1:foo}
*
* @return ${2:$1}
*/
${3:public} function get${4:$2}()
{ {
return $this->${3:$2}; return $this->${5:$1};
} }${6}
#setter #setter
snippet $s snippet $s
${1:$foo}->set${2:Bar}(${3}); ${1:$foo}->set${2:Bar}(${3});
@ -322,29 +329,29 @@ snippet http_redirect
header ("Location: ".URL); header ("Location: ".URL);
exit(); exit();
# Getters & Setters # Getters & Setters
snippet getset snippet gs
/** /**
* Gets the value of ${1:} * Gets the value of ${1:foo}
* *
* @return ${2:type} * @return ${2:$1}
*/ */
public function get${3:}() public function get${3:$2}()
{ {
return $this->$1; return $this->${4:$1};
} }
/** /**
* Sets the value of $1 * Sets the value of $1
* *
* @param $2 $$1 ${4} * @param $2 $$1 ${5:description}
* *
* @return ${5:`Filename()`} * @return ${6:`Filename()`}
*/ */
public function set$3(${6:$2} $$1) public function set$3(${7:$2 }$$1)
{ {
$this->$1 = $$1; $this->$4 = $$1;
return $this; return $this;
} }${8}
snippet rett snippet rett
return true; return true;
snippet retf snippet retf