-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathphp-getset.sublime-snippet
54 lines (43 loc) · 1.55 KB
/
php-getset.sublime-snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!--
php-getset
A time-saving device for creating getters & setters in PHP classes
Based on a snippet originall published by @akrabat:
http://akrabat.com/software/sublime-text-2-snippet-for-php-getter-and-setter-generation/
HOW TO USE
In your PHP class, simply type the following:
php-getset<TAB><name of your property without a $ sign>
Sublime Text will add the getter and setter to your class, and
name them after your property.
For example, if your property is called $connection, you would
go into your class, and type:
php-getset<TAB>connection
and Sublime Text will create getConnection() and setConnection()
methods for you.
-->
<snippet>
<content><![CDATA[
/**
* ${2:[description here]}
*
* @return ${3:[type]} ${4:[description]}
*/
public function get${1/(.*)/\u$1/:[ Prop name ]}() {
return \$this->${1:[ Prop name ]};
}
/**
* ${5:[Description]}
*
* @param ${3/(.*)/\u$1/:[type]} \$new${1:[ Prop name ]} ${4/(.*)/\u$1/:[description]}
*/
public function set${1/(.*)/\u$1/:[ Prop name ]}(\$${1/(.*)/$1/:[ Prop name ]}) {
\$this->${1:[Prop name ]} = \$${1/(.*)/$1/:[ Prop name ]};
return \$this;
}
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>php-getset</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Create getter and setter methods</description>
</snippet>