added my custom php snippets

This commit is contained in:
Jacek Wysocki 2012-06-22 11:50:22 +02:00
parent c7e78522fd
commit 74bd536002

View File

@ -5,20 +5,6 @@ snippet array "array"
$${1:arrayName} = array('${2}' => ${3});${4} $${1:arrayName} = array('${2}' => ${3});${4}
endsnippet endsnippet
snippet class "class"
/**
* ${1}
*/
class ${2:ClassName}
{
${3}
function ${4:__construct}(${5:argument})
{
${6:// code...}
}
}
endsnippet
snippet def "def" snippet def "def"
define('${1}'${2});${3} define('${1}'${2});${3}
endsnippet endsnippet
@ -107,4 +93,124 @@ snippet var "var"
var_export(${1});${2} var_export(${1});${2}
endsnippet endsnippet
snippet gs "PHP ClassGetter Setter" !b
protected $$1
/*
* Getter for $1
*/
public function get${1/\w+\s*/\u$0/}()
{
return $this->$1;$2
}
/*
* Setter for $1
*/
public function set${1/\w+\s*/\u$0/}($$1)
{
$this->$1 = $$1;$3
return $this;
}
$0
endsnippet
snippet pub "Public function" !b
public function ${1:name}(${2:$param})
{
${3:return null;}
}
endsnippet
snippet pro "Protected function" !b
protected function ${1:name}(${2:$param})
{
${3:return null;}
}
endsnippet
snippet pri "Private function" !b
private function ${1:name}(${2:$param})
{
${3:return null;}
}
endsnippet
snippet pubs "Public static function" !b
public static function ${1:name}(${2:$param})
{
${3:return null;}
}
endsnippet
snippet pros "Protected static function" !b
protected static function ${1:name}(${2:$param})
{
${3:return null;}
}
endsnippet
snippet pris "Private static function" !b
private static function ${1:name}(${2:$param})
{
${3:return null;}
}
endsnippet
snippet fu "Function snip" !b
function ${1:name}(${2:$param})
{
${3:return null;}
}
endsnippet
# :vim:ft=snippets
snippet fore "Foreach loop"
foreach ($${1:variable} as $${3:value}){
${4:// code...}
}
endsnippet
snippet new "New class instance" !b
$$1 = new $1($2);
$3
endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
} else {
${3:// code...}
}
endsnippet
snippet class "Class declaration template" !b
/**
* @author Jacek Wysocki <jacek.wysocki@gmail.com>
*/
class ${1:`!p snip.rv=snip.fn.capitalize().split('.')[0]`}
{
public function __construct(${2:$options=array()})
{
${3:if (is_array($options)) {
foreach ($options as $k => $v) {
$this->$k = $v;
}
}}$4
}
}
endsnippet
snippet pr "Demb debug helper in HTML"
echo '<pre>' . var_export($1, 1) . '</pre>';
endsnippet
snippet pc "Dumb debug helper in cli"
var_export($1);
endsnippet
# :vim:ft=snippets: # :vim:ft=snippets: