From 4a8ba6ff5bf684a2ae33904f8b3ff830745c5808 Mon Sep 17 00:00:00 2001 From: chrisyue Date: Fri, 27 Jul 2012 19:40:14 +0800 Subject: [PATCH] add new class and interface snippet, and some other improvement --- snippets/php.snippets | 63 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/snippets/php.snippets b/snippets/php.snippets index e231da5..a7ee9a7 100644 --- a/snippets/php.snippets +++ b/snippets/php.snippets @@ -6,11 +6,58 @@ snippet ec echo ${1}; snippet -# this is for php5.4 +# this one is for php5.4 snippet -snippet th - $this->${1:something} +snippet ns + namespace ${1:Foo\Bar\Baz}; + ${2} +snippet use + use ${1:Foo\Bar\Baz}; + ${2} +snippet c + ${1:abstract }class ${2:`Filename()`} + { + ${3} + } +snippet i + interface ${1:`Filename()`} + { + ${2} + } +snippet $t + $this->${1:foo} +snippet f + function ${1:foo}(${2}) + { + ${3:echo 'hello world';} + } +# method +snippet m + ${1:abstract }${2:protected}${3: static} function ${4:foo}(${5}) + { + ${6} + } +# 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')`}) + { + $this->${5:$4} = $$4; + ${6} + return $this; + } +# getter method +snippet gm + ${1:public} function get${2:Foo}() + { + return $this->${3:$2}; + } + +# the following are old ones snippet inc include '${1:file}';${2} snippet inc1 @@ -237,16 +284,6 @@ snippet foreachkil $${3:value}): ?> ${4:} -snippet fun - function ${1:FunctionName}(${2}) - { - ${3:// code...} - }${4} -snippet p - ${1:protected} function ${2:FunctionName}(${3}) - { - ${4:// code...} - }${5} # $... = array (...) snippet array $${1:arrayName} = array('${2}' => ${3});${4}