From e016f1f78f026064f3fc7d572e1128a9bda921b5 Mon Sep 17 00:00:00 2001 From: Mathew Attlee Date: Fri, 17 Jun 2016 14:47:00 +0100 Subject: [PATCH] Refactored PHP getter and setter snippets to have consistent triggers --- UltiSnips/php.snippets | 22 ++++++++++------------ snippets/php.snippets | 15 +++++++-------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets index 74b51cc..7ba51c7 100644 --- a/UltiSnips/php.snippets +++ b/UltiSnips/php.snippets @@ -3,7 +3,7 @@ priority -50 ## Snippets from SnipMate, taken from ## https://github.com/scrooloose/snipmate-snippets.git -snippet getter "PHP Class Getter" b +snippet gm "PHP Class Getter" b /** * Getter for $1 * @@ -11,11 +11,11 @@ snippet getter "PHP Class Getter" b */ public function get${1/\w+\s*/\u$0/}() { - return $this->$1;$3 + return $this->$1; } endsnippet -snippet setter "PHP Class Setter" b +snippet sm "PHP Class Setter" b /** * Setter for $1 * @@ -24,11 +24,10 @@ snippet setter "PHP Class Setter" b */ public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) { - $this->$1 = $$1;$5 + $this->$1 = $$1; - ${6:return $this;} + ${5:return $this;} } -$0 endsnippet snippet gs "PHP Class Getter Setter" b @@ -39,22 +38,21 @@ snippet gs "PHP Class Getter Setter" b */ public function get${1/\w+\s*/\u$0/}() { - return $this->$1;$3 + return $this->$1; } /** * Setter for $1 * * @param $2 $$1 - * @return ${4:`!p snip.rv=snip.basename`} + * @return ${3:`!p snip.rv=snip.basename`} */ -public function set${1/\w+\s*/\u$0/}(${5:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) +public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) { - $this->$1 = $$1;$6 + $this->$1 = $$1; - ${7:return $this;} + ${5:return $this;} } -$0 endsnippet snippet pub "Public function" b diff --git a/snippets/php.snippets b/snippets/php.snippets index 826b845..4faa167 100644 --- a/snippets/php.snippets +++ b/snippets/php.snippets @@ -47,28 +47,27 @@ snippet m { ${0} } -# setter method -snippet sm +snippet sm "PHP Class Setter" /** * Sets the value of ${1:foo} * - * @param ${2:$1} $$1 ${3:description} + * @param ${2:string} $$1 ${3:description} * * @return ${4:`vim_snippets#Filename()`} */ - ${5:public} function set${6:$2}(${7:$2 }$$1) + ${5:public} function set${6:$1}(${7:$2 }$$1) { $this->${8:$1} = $$1; + return $this; } -# getter method -snippet gm +snippet gm "PHP Class Getter Setter" /** * Gets the value of ${1:foo} * - * @return ${2:$1} + * @return ${2:string} */ - ${3:public} function get${4:$2}() + ${3:public} function get${4:$1}() { return $this->${5:$1}; }