Merge pull request #156 from chrisyue/master

make setter and getter even better
This commit is contained in:
Honza Pokorny 2012-12-03 10:37:51 -08:00
commit 798e9ff2e1

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});
@ -195,7 +202,7 @@ snippet interface
* @package ${3:default} * @package ${3:default}
* @author ${4:`g:snips_author`} * @author ${4:`g:snips_author`}
*/ */
interface ${1:} interface ${1:`Filename()`}
{ {
${5} ${5}
} }
@ -204,7 +211,7 @@ snippet class
/** /**
* ${1} * ${1}
*/ */
class ${2:ClassName} class ${2:`Filename()`}
{ {
${3} ${3}
/** /**
@ -322,27 +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} * @return ${2:$1}
*/ */
public function get$1() public function get${3:$2}()
{ {
return $this->$1; return $this->${4:$1};
} }
/** /**
* Sets the value of $1 * Sets the value of $1
* *
* @param mixed $$1 ${3} * @param $2 $$1 ${5:description}
*
* @return ${6:`Filename()`}
*/ */
public function set$1($$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