Skip to content

Commit 9f8dd87

Browse files
author
Jacob Lambert
committed
Update PHP snippits
1 parent db35205 commit 9f8dd87

1 file changed

Lines changed: 67 additions & 58 deletions

File tree

extensions/php/snippets/php.json

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,75 @@
11
{
2-
"Class Variable": {
3-
"prefix": "doc_v",
2+
"class …": {
3+
"prefix": "class",
4+
"body": [
5+
"class ${1:ClassName} ${2:extends ${3:AnotherClass}} ${4:implements ${5:Interface}}",
6+
"{",
7+
"\t$0",
8+
"}",
9+
""
10+
],
11+
"description": "Class definition"
12+
},
13+
"PHPDoc class …": {
14+
"prefix": "doc_class",
415
"body": [
516
"/**",
6-
" * ${1:undocumented class variable}",
7-
" *",
8-
" * @var ${2:string}",
9-
" **/",
10-
"${3:var} $$2;$0"
17+
" * ${6:undocumented class}",
18+
" */",
19+
"class ${1:ClassName} ${2:extends ${3:AnotherClass}} ${4:implements ${5:Interface}}",
20+
"{",
21+
"\t$0",
22+
"}",
23+
""
1124
],
12-
"description": "Documented Class Variable"
25+
"description": "Documented Class Declaration"
1326
},
1427
"function __construct": {
1528
"prefix": "con",
1629
"body": [
17-
"function __construct(${1:$${2:foo} ${3:= ${4:null}}}) {",
18-
"\t${2:$this->$0 = $$0;}",
19-
"}"
30+
"${1:public} function __construct(${2:${3:Type} $${4:var}${5: = ${6:null}}}) {",
31+
"\t\\$this->${4:var} = $${4:var};$0",
32+
"}"
2033
]
2134
},
22-
"class …": {
23-
"prefix": "class",
35+
"PHPDoc property": {
36+
"prefix": "doc_v",
2437
"body": [
25-
"/**",
26-
" * $1",
27-
" */",
28-
"class ${2:ClassName} ${3:extends ${4:AnotherClass}}",
29-
"{",
30-
"\t$5",
31-
"\tfunction ${6:__construct}(${7:argument})",
32-
"\t{",
33-
"\t\t${0:# code...}",
34-
"\t}",
35-
"}",
36-
""
38+
"/** @var ${1:Type} $${2:var} ${3:description} */",
39+
"${4:protected} $${2:var}${5: = ${6:null}};$0"
3740
],
38-
"description": "Class definition"
41+
"description": "Documented Class Variable"
3942
},
4043
"PHPDoc function …": {
4144
"prefix": "doc_f",
4245
"body": [
4346
"/**",
44-
" * ${6:undocumented function summary}",
47+
" * ${1:undocumented function summary}",
4548
" *",
46-
" * ${7:Undocumented function long description}",
49+
" * ${2:Undocumented function long description}",
4750
" *",
48-
" * @param ${8:type} ${9:var} ${10:Description}",
51+
"${3: * @param ${4:Type} $${5:var} ${6:Description}}",
52+
"${7: * @return ${8:type}}",
53+
"${9: * @throws ${10:conditon}}",
4954
" **/",
50-
"${1:public }function ${2:FunctionName}(${3:$${4:value}${5:=''}})",
55+
"${11:public }function ${12:FunctionName}(${13:${14:${4:Type} }$${5:var}${15: = ${16:null}}})",
5156
"{",
5257
"\t${0:# code...}",
5358
"}"
5459
],
5560
"description": "Documented function"
5661
},
62+
"PHPDoc param …": {
63+
"prefix": "param",
64+
"body": [
65+
"* @param ${1:Type} ${2:var} ${3:Description}$0"
66+
],
67+
"description": "Paramater documentation"
68+
},
5769
"function …": {
5870
"prefix": "fun",
5971
"body": [
60-
"${1:public }function ${2:FunctionName}(${3:$${4:value}${5:=''}})",
72+
"${1:public }function ${2:FunctionName}(${3:${4:${5:Type} }$${6:var}${7: = ${8:null}}})",
6173
"{",
6274
"\t${0:# code...}",
6375
"}"
@@ -72,10 +84,7 @@
7284
" */",
7385
"trait ${2:TraitName}",
7486
"{",
75-
"\tfunction ${3:functionName}(${4:argument})",
76-
"\t{",
77-
"\t\t${5:# code...}",
78-
"\t}",
87+
"\t$0",
7988
"}",
8089
""
8190
],
@@ -94,21 +103,18 @@
94103
"body": [
95104
"do {",
96105
"\t${0:# code...}",
97-
"} while (${1:${2:$a} <= ${3:10}});"
106+
"} while (${1:$${2:a} <= ${3:10}});"
98107
],
99108
"description": "Do-While loop"
100109
},
101-
"if … else …": {
102-
"prefix": "ifelse",
110+
"while …": {
111+
"prefix": "while",
103112
"body": [
104-
"if (${1:condition}) {",
105-
"\t${2:# code...}",
106-
"} else {",
107-
"\t${3:# code...}",
108-
"}",
109-
"$0"
113+
"while (${1:$${2:a} <= ${3:10}}) {",
114+
"\t${0:# code...}",
115+
"}"
110116
],
111-
"description": "If Else block"
117+
"description": "While-loop"
112118
},
113119
"if …": {
114120
"prefix": "if",
@@ -119,6 +125,18 @@
119125
],
120126
"description": "If block"
121127
},
128+
"if … else …": {
129+
"prefix": "ifelse",
130+
"body": [
131+
"if (${1:condition}) {",
132+
"\t${2:# code...}",
133+
"} else {",
134+
"\t${3:# code...}",
135+
"}",
136+
"$0"
137+
],
138+
"description": "If Else block"
139+
},
122140
"$… = ( … ) ? … : …": {
123141
"prefix": "if?",
124142
"body": "$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b} ;",
@@ -178,7 +196,7 @@
178196
"switch …": {
179197
"prefix": "switch",
180198
"body": [
181-
"switch (${1:variable}) {",
199+
"switch (\\$${1:variable}) {",
182200
"\tcase '${2:value}':",
183201
"\t\t${3:# code...}",
184202
"\t\tbreak;",
@@ -193,20 +211,20 @@
193211
"case …": {
194212
"prefix": "case",
195213
"body": [
196-
"case '${1:variable}':",
214+
"case '${1:value}':",
197215
"\t${0:# code...}",
198216
"\tbreak;"
199217
],
200218
"description": "Case Block"
201219
},
202220
"$this->…": {
203221
"prefix": "this",
204-
"body": "$this->$0",
222+
"body": "\\$this->$0;",
205223
"description": "$this->..."
206224
},
207225
"echo $this->…": {
208226
"prefix": "ethis",
209-
"body": "echo $this->$0",
227+
"body": "echo \\$this->$0;",
210228
"description": "Echo this"
211229
},
212230
"Throw Exception": {
@@ -216,14 +234,5 @@
216234
"$0"
217235
],
218236
"description": "Throw exception"
219-
},
220-
"while …": {
221-
"prefix": "while",
222-
"body": [
223-
"while (${1:$a <= 10}) {",
224-
"\t${0:# code...}",
225-
"}"
226-
],
227-
"description": "While-loop"
228237
}
229238
}

0 commit comments

Comments
 (0)