Skip to content

Commit 798e9ff

Browse files
committed
Merge pull request honza#156 from chrisyue/master
make setter and getter even better
2 parents 3735165 + 12f2641 commit 798e9ff

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

snippets/php.snippets

+31-22
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,30 @@ snippet m
3939
${7}
4040
}
4141
# setter method
42-
# I think vim's functions will not be called at the snipMate's runtime
43-
# but `compile` time
44-
# so `tolower` here won't work
45-
# but it would be wonderful if we could make the property and parameter to lower case
4642
snippet sm
47-
${1:public} function set${2:Foo}(${3:$2 }$${4:`tolower('$2')`})
43+
/**
44+
* Sets the value of ${1:foo}
45+
*
46+
* @param ${2:$1} $$1 ${3:description}
47+
*
48+
* @return ${4:`Filename()`}
49+
*/
50+
${5:public} function set${6:$2}(${7:$2 }$$1)
4851
{
49-
$this->${5:$4} = $$4;
50-
${6}
52+
$this->${8:$1} = $$1;
5153
return $this;
52-
}
54+
}${9}
5355
# getter method
5456
snippet gm
55-
${1:public} function get${2:Foo}()
57+
/**
58+
* Gets the value of ${1:foo}
59+
*
60+
* @return ${2:$1}
61+
*/
62+
${3:public} function get${4:$2}()
5663
{
57-
return $this->${3:$2};
58-
}
64+
return $this->${5:$1};
65+
}${6}
5966
#setter
6067
snippet $s
6168
${1:$foo}->set${2:Bar}(${3});
@@ -195,7 +202,7 @@ snippet interface
195202
* @package ${3:default}
196203
* @author ${4:`g:snips_author`}
197204
*/
198-
interface ${1:}
205+
interface ${1:`Filename()`}
199206
{
200207
${5}
201208
}
@@ -204,7 +211,7 @@ snippet class
204211
/**
205212
* ${1}
206213
*/
207-
class ${2:ClassName}
214+
class ${2:`Filename()`}
208215
{
209216
${3}
210217
/**
@@ -322,27 +329,29 @@ snippet http_redirect
322329
header ("Location: ".URL);
323330
exit();
324331
# Getters & Setters
325-
snippet getset
332+
snippet gs
326333
/**
327-
* Gets the value of ${1:}
334+
* Gets the value of ${1:foo}
328335
*
329-
* @return ${2}
336+
* @return ${2:$1}
330337
*/
331-
public function get$1()
338+
public function get${3:$2}()
332339
{
333-
return $this->$1;
340+
return $this->${4:$1};
334341
}
335342

336343
/**
337344
* Sets the value of $1
338345
*
339-
* @param mixed $$1 ${3}
346+
* @param $2 $$1 ${5:description}
347+
*
348+
* @return ${6:`Filename()`}
340349
*/
341-
public function set$1($$1)
350+
public function set$3(${7:$2 }$$1)
342351
{
343-
$this->$1 = $$1;
352+
$this->$4 = $$1;
344353
return $this;
345-
}
354+
}${8}
346355
snippet rett
347356
return true;
348357
snippet retf

0 commit comments

Comments
 (0)