From 12f2641e9d0acdf77ea07e352093feb8ff335d34 Mon Sep 17 00:00:00 2001 From: chrisyue Date: Tue, 4 Dec 2012 00:18:40 +0800 Subject: [PATCH] make getter and setter even better --- snippets/php.snippets | 49 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/snippets/php.snippets b/snippets/php.snippets index 05005d5..dd529d9 100644 --- a/snippets/php.snippets +++ b/snippets/php.snippets @@ -39,23 +39,30 @@ snippet m ${7} } # 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 - ${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; - ${6} + $this->${8:$1} = $$1; return $this; - } + }${9} # getter method 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 snippet $s ${1:$foo}->set${2:Bar}(${3}); @@ -322,29 +329,29 @@ snippet http_redirect header ("Location: ".URL); exit(); # 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 * - * @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; - } + }${8} snippet rett return true; snippet retf