|
1 |
| -## Snippets from SnipMate, taken from |
2 |
| -## https://github.com/scrooloose/snipmate-snippets.git |
| 1 | +snippet <? "php open tag" b |
| 2 | +<?php |
3 | 3 |
|
4 |
| -snippet array "array" |
5 |
| -$${1:arrayName} = array('${2}' => ${3});${4} |
6 |
| -endsnippet |
7 |
| - |
8 |
| -snippet def "def" |
9 |
| -define('${1}'${2});${3} |
10 |
| -endsnippet |
11 |
| - |
12 |
| -snippet do "do" |
13 |
| -do { |
14 |
| - ${2} |
15 |
| -} while (${1});" |
16 |
| -endsnippet |
17 |
| - |
18 |
| -snippet doc_f "doc_f" |
19 |
| -/** |
20 |
| - * $2 |
21 |
| - * @return ${4:void} |
22 |
| - * @author ${5:`!v g:snips_author`} |
23 |
| - **/ |
24 |
| -${1:public }function ${2:someFunc}(${3}) |
25 |
| -{${6} |
26 |
| -} |
27 |
| -endsnippet |
28 |
| - |
29 |
| -snippet doc_i "doc_i" |
30 |
| -/** |
31 |
| - * $1 |
32 |
| - * @package ${2:default} |
33 |
| - * @author ${3:`!v g:snips_author`} |
34 |
| - **/ |
35 |
| -interface ${1:someClass} |
36 |
| -{${4} |
37 |
| -} // END interface $1" |
38 |
| -endsnippet |
39 |
| - |
40 |
| -snippet el "else" |
41 |
| -else { |
42 |
| - ${1} |
43 |
| -} |
44 |
| -endsnippet |
45 |
| - |
46 |
| -snippet for "for" |
47 |
| -for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { |
48 |
| - ${4} |
49 |
| -} |
50 |
| -endsnippet |
51 |
| - |
52 |
| -snippet foreachk "foreachk" |
53 |
| -foreach ($${1:variable} as $${2:key} => $${3:value}){ |
54 |
| - ${4} |
55 |
| -} |
56 |
| -endsnippet |
57 | 4 |
|
58 |
| -snippet get "get" |
59 |
| -$_GET['${1}']${2} |
60 | 5 | endsnippet
|
61 | 6 |
|
62 |
| -snippet if "if" |
63 |
| -if (${1}) { |
64 |
| - ${2} |
65 |
| -} |
66 |
| -endsnippet |
67 |
| - |
68 |
| -snippet inc "inc" |
69 |
| -include '${1:file}';${2} |
70 |
| -endsnippet |
71 |
| - |
72 |
| -snippet log "log" |
73 |
| -error_log(var_export(${1}, true));${2} |
74 |
| -endsnippet |
75 |
| - |
76 |
| -snippet post "post" |
77 |
| -$_POST['${1}']${2} |
78 |
| -endsnippet |
79 |
| - |
80 |
| -snippet req1 "req1" |
81 |
| -require_once '${1:file}';${2} |
| 7 | +snippet vdd "php var_dump and die" b |
| 8 | +var_dump(); die(); |
82 | 9 | endsnippet
|
83 | 10 |
|
84 |
| -snippet session "session" |
85 |
| -$_SESSION['${1}']${2} |
86 |
| -endsnippet |
87 |
| - |
88 |
| -snippet t "t" |
89 |
| -$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} |
90 |
| -endsnippet |
91 |
| - |
92 |
| -snippet var "var" |
93 |
| -var_export(${1});${2} |
94 |
| -endsnippet |
95 |
| - |
96 |
| -snippet getter "PHP Class Getter" !b |
97 |
| -/* |
98 |
| - * Getter for $1 |
99 |
| - */ |
100 |
| -public function get${1/\w+\s*/\u$0/}() |
101 |
| -{ |
102 |
| - return $this->$1;$2 |
103 |
| -} |
104 |
| -$4 |
105 |
| -endsnippet |
106 |
| - |
107 |
| -snippet setter "PHP Class Setter" !b |
108 |
| -/* |
109 |
| - * Setter for $1 |
110 |
| - */ |
111 |
| -public function set${1/\w+\s*/\u$0/}($$1) |
112 |
| -{ |
113 |
| - $this->$1 = $$1;$3 |
114 |
| - ${4:return $this;} |
115 |
| -} |
116 |
| -$0 |
| 11 | +snippet ns "php namespace" b |
| 12 | +namespace ${1:`!p |
| 13 | +abspath = os.path.abspath(path) |
| 14 | +m = re.search(r'[A-Z].+(?=/)', abspath) |
| 15 | +if m: |
| 16 | + snip.rv = m.group().replace('/', '\\') |
| 17 | +`}; |
117 | 18 | endsnippet
|
118 | 19 |
|
119 |
| -snippet gs "PHP Class Getter Setter" !b |
120 |
| -protected $$1 |
| 20 | +snippet nc "php namespace and class" b |
| 21 | +namespace ${1:`!p |
| 22 | +abspath = os.path.abspath(path) |
| 23 | +m = re.search(r'[A-Z].+(?=/)', abspath) |
| 24 | +if m: |
| 25 | + snip.rv = m.group().replace('/', '\\') |
| 26 | +`}; |
121 | 27 |
|
122 |
| -/* |
123 |
| - * Getter for $1 |
124 |
| - */ |
125 |
| -public function get${1/\w+\s*/\u$0/}() |
126 |
| -{ |
127 |
| - return $this->$1;$2 |
128 |
| -} |
129 |
| - |
130 |
| -/* |
131 |
| - * Setter for $1 |
| 28 | +/** |
| 29 | + * ${3:@author `whoami`}$4 |
132 | 30 | */
|
133 |
| -public function set${1/\w+\s*/\u$0/}($$1) |
134 |
| -{ |
135 |
| - $this->$1 = $$1;$3 |
136 |
| - ${4:return $this;} |
137 |
| -} |
138 |
| -$0 |
139 |
| -endsnippet |
140 |
| - |
141 |
| -snippet pub "Public function" !b |
142 |
| -public function ${1:name}(${2:$param}) |
| 31 | +class ${2:`!p |
| 32 | +snip.rv = re.match(r'.*(?=\.)', fn).group().capitalize() |
| 33 | +`} |
143 | 34 | {
|
144 |
| - ${VISUAL}${3:return null;} |
145 | 35 | }
|
146 |
| -$0 |
147 | 36 | endsnippet
|
148 | 37 |
|
149 |
| -snippet pro "Protected function" !b |
150 |
| -protected function ${1:name}(${2:$param}) |
| 38 | +snippet st "php static function" b |
| 39 | +${1:public} static function $2($3) |
151 | 40 | {
|
152 |
| - ${VISUAL}${3:return null;} |
153 |
| -} |
154 |
| -$0 |
155 |
| -endsnippet |
156 |
| - |
157 |
| -snippet pri "Private function" !b |
158 |
| -private function ${1:name}(${2:$param}) |
159 |
| -{ |
160 |
| - ${VISUAL}${3:return null;} |
161 |
| -} |
162 |
| -$0 |
163 |
| -endsnippet |
164 |
| - |
165 |
| -snippet pubs "Public static function" !b |
166 |
| -public static function ${1:name}(${2:$param}) |
167 |
| -{ |
168 |
| - ${VISUAL}${3:return null;} |
169 |
| -} |
170 |
| -$0 |
171 |
| -endsnippet |
172 |
| - |
173 |
| -snippet pros "Protected static function" !b |
174 |
| -protected static function ${1:name}(${2:$param}) |
175 |
| -{ |
176 |
| - ${VISUAL}${3:return null;} |
177 |
| -} |
178 |
| -$0 |
179 |
| -endsnippet |
180 |
| - |
181 |
| -snippet pris "Private static function" !b |
182 |
| -private static function ${1:name}(${2:$param}) |
183 |
| -{ |
184 |
| - ${VISUAL}${3:return null;} |
| 41 | + ${4} |
185 | 42 | }
|
186 |
| -$0 |
187 | 43 | endsnippet
|
188 | 44 |
|
189 |
| -snippet fu "Function snip" !b |
190 |
| -function ${1:name}(${2:$param}) |
| 45 | +snippet __ "php constructor" b |
| 46 | +${1:public} function __construct($2) |
191 | 47 | {
|
192 |
| - ${VISUAL}${3:return null;} |
193 |
| -} |
194 |
| -$0 |
195 |
| -endsnippet |
196 |
| -# :vim:ft=snippets |
197 |
| - |
198 |
| -snippet fore "Foreach loop" |
199 |
| -foreach ($${1:variable} as $${3:value}){ |
200 |
| - ${VISUAL}${4} |
201 |
| -} |
202 |
| -$0 |
203 |
| -endsnippet |
204 |
| - |
205 |
| -snippet new "New class instance" !b |
206 |
| -$$1 = new $1($2); |
207 |
| -$0 |
208 |
| -endsnippet |
209 |
| - |
210 |
| - |
211 |
| -snippet ife "if else" |
212 |
| -if (${1:/* condition */}) { |
213 |
| - ${2} |
214 |
| -} else { |
215 |
| - ${3} |
| 48 | + ${3} |
216 | 49 | }
|
217 |
| -$0 |
218 | 50 | endsnippet
|
219 | 51 |
|
| 52 | +snippet sg "Setter and Getter" b |
220 | 53 |
|
221 |
| -snippet class "Class declaration template" !b |
222 | 54 | /**
|
223 |
| - * Class ${1:`!p snip.rv=snip.fn.capitalize().split('.')[0]`} |
224 |
| - * @author $2 |
| 55 | + * @var ${3:`!p snip.rv = t[2].capitalize()`}${4} |
225 | 56 | */
|
226 |
| -class $1 |
| 57 | +${1:protected} $$2; |
| 58 | + |
| 59 | +public function set`!p snip.rv = t[2].capitalize()`(`!p |
| 60 | +if re.match(r'[A-Z].*', t[3]): |
| 61 | + snip.rv = t[3] + ' ' |
| 62 | +else: |
| 63 | + snip.rv = '' |
| 64 | +`$$2) |
227 | 65 | {
|
228 |
| - public function ${3:__construct}(${4:$options}) |
229 |
| - { |
230 |
| - ${4} |
231 |
| - } |
232 |
| -} |
233 |
| -$0 |
234 |
| -endsnippet |
| 66 | + $this->$2 = $$2; |
235 | 67 |
|
236 |
| -snippet pr "Dumb debug helper in HTML" |
237 |
| -echo '<pre>' . var_export($1, 1) . '</pre>';$0 |
238 |
| -endsnippet |
239 |
| - |
240 |
| -snippet pc "Dumb debug helper in cli" |
241 |
| -var_export($1);$0 |
242 |
| -endsnippet |
243 |
| - |
244 |
| -# Symfony 2 based snippets |
245 |
| -snippet sfa "Symfony 2 Controller action" |
246 |
| -/** |
247 |
| -* @Route("/${1:route_name}", name="$1") |
248 |
| -* @Template() |
249 |
| -*/ |
250 |
| -public function $1Action($2) |
251 |
| -{ |
252 |
| - $3 |
253 |
| - return ${4:array();}$0 |
| 68 | + return $this; |
254 | 69 | }
|
255 | 70 | endsnippet
|
256 |
| - |
257 |
| -# :vim:ft=snippets: |
258 |
| - |
0 commit comments