From ffcf23092b9d21de174f523687d43e3f6dc3b8c1 Mon Sep 17 00:00:00 2001 From: Darrell Hamilton Date: Sun, 2 Dec 2012 15:13:11 -0800 Subject: [PATCH 1/3] Use Filename() for interface and class name default values --- snippets/php.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/php.snippets b/snippets/php.snippets index 9ce93d4..47accd8 100644 --- a/snippets/php.snippets +++ b/snippets/php.snippets @@ -195,7 +195,7 @@ snippet interface * @package ${3:default} * @author ${4:`g:snips_author`} */ - interface ${1:} + interface ${1:`Filename()`} { ${5} } @@ -204,7 +204,7 @@ snippet class /** * ${1} */ - class ${2:ClassName} + class ${2:`Filename()`} { ${3} /** From 8cc31cd9d0f38ccc7b2197740e1143b68124b475 Mon Sep 17 00:00:00 2001 From: Darrell Hamilton Date: Sun, 2 Dec 2012 15:14:30 -0800 Subject: [PATCH 2/3] Improved getset snippet - Reuse getter @return type for type hinting in the setter - Separate property and method names to compensate for case differences --- snippets/php.snippets | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/snippets/php.snippets b/snippets/php.snippets index 9ce93d4..7d569cb 100644 --- a/snippets/php.snippets +++ b/snippets/php.snippets @@ -326,9 +326,9 @@ snippet getset /** * Gets the value of ${1:} * - * @return ${2} + * @return ${2:type} */ - public function get$1() + public function get${3:}() { return $this->$1; } @@ -336,9 +336,11 @@ snippet getset /** * Sets the value of $1 * - * @param mixed $$1 ${3} + * @param $2 $$1 ${4} + * + * @return ${5:`Filename()`} */ - public function set$1($$1) + public function set$3(${6:$2} $$1) { $this->$1 = $$1; return $this; From 12f2641e9d0acdf77ea07e352093feb8ff335d34 Mon Sep 17 00:00:00 2001 From: chrisyue Date: Tue, 4 Dec 2012 00:18:40 +0800 Subject: [PATCH 3/3] 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