Merge pull request #156 from chrisyue/master
make setter and getter even better
This commit is contained in:
commit
798e9ff2e1
@ -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});
|
||||
@ -195,7 +202,7 @@ snippet interface
|
||||
* @package ${3:default}
|
||||
* @author ${4:`g:snips_author`}
|
||||
*/
|
||||
interface ${1:}
|
||||
interface ${1:`Filename()`}
|
||||
{
|
||||
${5}
|
||||
}
|
||||
@ -204,7 +211,7 @@ snippet class
|
||||
/**
|
||||
* ${1}
|
||||
*/
|
||||
class ${2:ClassName}
|
||||
class ${2:`Filename()`}
|
||||
{
|
||||
${3}
|
||||
/**
|
||||
@ -322,27 +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}
|
||||
* @return ${2:$1}
|
||||
*/
|
||||
public function get$1()
|
||||
public function get${3:$2}()
|
||||
{
|
||||
return $this->$1;
|
||||
return $this->${4:$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;
|
||||
}
|
||||
}${8}
|
||||
snippet rett
|
||||
return true;
|
||||
snippet retf
|
||||
|
Loading…
Reference in New Issue
Block a user