Merge pull request #755 from codeinabox/php-getter-setter
Refactored PHP getter and setter snippets to have consistent triggers
This commit is contained in:
commit
86d5bb58b1
@ -3,7 +3,7 @@ priority -50
|
|||||||
## Snippets from SnipMate, taken from
|
## Snippets from SnipMate, taken from
|
||||||
## https://github.com/scrooloose/snipmate-snippets.git
|
## https://github.com/scrooloose/snipmate-snippets.git
|
||||||
|
|
||||||
snippet getter "PHP Class Getter" b
|
snippet gm "PHP Class Getter" b
|
||||||
/**
|
/**
|
||||||
* Getter for $1
|
* Getter for $1
|
||||||
*
|
*
|
||||||
@ -11,11 +11,11 @@ snippet getter "PHP Class Getter" b
|
|||||||
*/
|
*/
|
||||||
public function get${1/\w+\s*/\u$0/}()
|
public function get${1/\w+\s*/\u$0/}()
|
||||||
{
|
{
|
||||||
return $this->$1;$3
|
return $this->$1;
|
||||||
}
|
}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet setter "PHP Class Setter" b
|
snippet sm "PHP Class Setter" b
|
||||||
/**
|
/**
|
||||||
* Setter for $1
|
* 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)
|
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
|
endsnippet
|
||||||
|
|
||||||
snippet gs "PHP Class Getter Setter" b
|
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/}()
|
public function get${1/\w+\s*/\u$0/}()
|
||||||
{
|
{
|
||||||
return $this->$1;$3
|
return $this->$1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for $1
|
* Setter for $1
|
||||||
*
|
*
|
||||||
* @param $2 $$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
|
endsnippet
|
||||||
|
|
||||||
snippet pub "Public function" b
|
snippet pub "Public function" b
|
||||||
|
@ -47,28 +47,27 @@ snippet m
|
|||||||
{
|
{
|
||||||
${0}
|
${0}
|
||||||
}
|
}
|
||||||
# setter method
|
snippet sm "PHP Class Setter"
|
||||||
snippet sm
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of ${1:foo}
|
* Sets the value of ${1:foo}
|
||||||
*
|
*
|
||||||
* @param ${2:$1} $$1 ${3:description}
|
* @param ${2:string} $$1 ${3:description}
|
||||||
*
|
*
|
||||||
* @return ${4:`vim_snippets#Filename()`}
|
* @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;
|
$this->${8:$1} = $$1;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
# getter method
|
snippet gm "PHP Class Getter Setter"
|
||||||
snippet gm
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of ${1:foo}
|
* 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};
|
return $this->${5:$1};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user