vscode/extensions/php/snippets/php.snippets.json

263 lines
5.1 KiB
JSON
Raw Normal View History

2015-11-13 13:39:38 +00:00
{
2017-03-10 04:23:15 +00:00
"class …": {
"prefix": "class",
"body": [
"class ${1:ClassName} ${2:extends ${3:AnotherClass}} ${4:implements ${5:Interface}}",
"{",
"\t$0",
"}",
""
],
"description": "Class definition"
},
"PHPDoc class …": {
"prefix": "doc_class",
2015-11-13 13:39:38 +00:00
"body": [
"/**",
2017-03-10 04:23:15 +00:00
" * ${6:undocumented class}",
" */",
"class ${1:ClassName} ${2:extends ${3:AnotherClass}} ${4:implements ${5:Interface}}",
"{",
"\t$0",
"}",
""
2015-11-13 13:39:38 +00:00
],
2017-03-10 04:23:15 +00:00
"description": "Documented Class Declaration"
2015-11-13 13:39:38 +00:00
},
"function __construct": {
"prefix": "con",
"body": [
2017-03-10 04:23:15 +00:00
"${1:public} function __construct(${2:${3:Type} $${4:var}${5: = ${6:null}}}) {",
"\t\\$this->${4:var} = $${4:var};$0",
"}"
2015-11-13 13:39:38 +00:00
]
},
2017-03-10 04:23:15 +00:00
"PHPDoc property": {
"prefix": "doc_v",
2015-11-13 13:39:38 +00:00
"body": [
2017-03-10 04:23:15 +00:00
"/** @var ${1:Type} $${2:var} ${3:description} */",
"${4:protected} $${2:var}${5: = ${6:null}};$0"
2015-11-13 13:39:38 +00:00
],
2017-03-10 04:23:15 +00:00
"description": "Documented Class Variable"
2015-11-13 13:39:38 +00:00
},
"PHPDoc function …": {
"prefix": "doc_f",
"body": [
"/**",
2017-03-10 04:23:15 +00:00
" * ${1:undocumented function summary}",
2015-11-13 13:39:38 +00:00
" *",
2017-03-10 04:23:15 +00:00
" * ${2:Undocumented function long description}",
2015-11-13 13:39:38 +00:00
" *",
2017-03-10 04:23:15 +00:00
"${3: * @param ${4:Type} $${5:var} ${6:Description}}",
"${7: * @return ${8:type}}",
"${9: * @throws ${10:conditon}}",
2015-11-13 13:39:38 +00:00
" **/",
2017-03-10 04:23:15 +00:00
"${11:public }function ${12:FunctionName}(${13:${14:${4:Type} }$${5:var}${15: = ${16:null}}})",
2015-11-13 13:39:38 +00:00
"{",
"\t${0:# code...}",
"}"
],
"description": "Documented function"
},
2017-03-10 04:23:15 +00:00
"PHPDoc param …": {
"prefix": "param",
"body": [
"* @param ${1:Type} ${2:var} ${3:Description}$0"
],
"description": "Paramater documentation"
},
2015-11-13 13:39:38 +00:00
"function …": {
"prefix": "fun",
"body": [
2017-03-10 04:23:15 +00:00
"${1:public }function ${2:FunctionName}(${3:${4:${5:Type} }$${6:var}${7: = ${8:null}}})",
2015-11-13 13:39:38 +00:00
"{",
"\t${0:# code...}",
"}"
],
"description": "Function"
},
"trait …": {
"prefix": "trait",
"body": [
"/**",
" * $1",
" */",
"trait ${2:TraitName}",
"{",
2017-03-10 04:23:15 +00:00
"\t$0",
2015-11-13 13:39:38 +00:00
"}",
""
],
"description": "Trait"
},
"define(…, …)": {
"prefix": "def",
"body": [
"define('$1', ${2:'$3'});",
"$0"
],
"description": "Definition"
},
"do … while …": {
"prefix": "do",
"body": [
"do {",
"\t${0:# code...}",
2017-03-10 04:23:15 +00:00
"} while (${1:$${2:a} <= ${3:10}});"
2015-11-13 13:39:38 +00:00
],
"description": "Do-While loop"
},
2017-03-10 04:23:15 +00:00
"while …": {
"prefix": "while",
2015-11-13 13:39:38 +00:00
"body": [
2017-03-10 04:23:15 +00:00
"while (${1:$${2:a} <= ${3:10}}) {",
"\t${0:# code...}",
"}"
2015-11-13 13:39:38 +00:00
],
2017-03-10 04:23:15 +00:00
"description": "While-loop"
2015-11-13 13:39:38 +00:00
},
"if …": {
"prefix": "if",
"body": [
"if (${1:condition}) {",
"\t${0:# code...}",
"}"
],
"description": "If block"
},
2017-03-10 04:23:15 +00:00
"if … else …": {
"prefix": "ifelse",
"body": [
"if (${1:condition}) {",
"\t${2:# code...}",
"} else {",
"\t${3:# code...}",
"}",
"$0"
],
"description": "If Else block"
},
2015-11-13 13:39:38 +00:00
"$… = ( … ) ? … : …": {
"prefix": "if?",
"body": "$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b} ;",
"description": "Ternary conditional assignment"
},
"else …": {
"prefix": "else",
"body": [
"else {",
"\t${0:# code...}",
"}"
],
"description": "Else block"
},
"elseif …": {
"prefix": "elseif",
"body": [
"elseif (${1:condition}) {",
"\t${0:# code...}",
"}"
],
"description": "Elseif block"
},
"for …": {
"prefix": "for",
"body": [
"for ($${1:i}=${2:0}; $${1:i} < $3; $${1:i}++) { ",
"\t${0:# code...}",
"}"
],
"description": "For-loop"
},
"foreach …": {
"prefix": "foreach",
"body": [
"foreach ($${1:variable} as $${2:key} ${3:=> $${4:value}}) {",
"\t${0:# code...}",
"}"
],
"description": "Foreach loop"
},
"$… = array (…)": {
"prefix": "array",
"body": "$${1:arrayName} = array('$2' => $3${4:,} $0);",
"description": "Array initializer"
},
"$… = […]": {
"prefix": "shorray",
"body": "$${1:arrayName} = ['$2' => $3${4:,} $0];",
"description": "Array initializer"
},
"… => …": {
"prefix": "keyval",
"body": "'$1' => $2${3:,} $0",
"description": "Key-Value initializer"
},
"switch …": {
"prefix": "switch",
"body": [
2017-03-10 04:23:15 +00:00
"switch (\\$${1:variable}) {",
2015-11-13 13:39:38 +00:00
"\tcase '${2:value}':",
"\t\t${3:# code...}",
"\t\tbreak;",
"\t$0",
"\tdefault:",
"\t\t${4:# code...}",
"\t\tbreak;",
"}"
],
"description": "Switch block"
},
"case …": {
"prefix": "case",
"body": [
2017-03-10 04:23:15 +00:00
"case '${1:value}':",
2015-11-13 13:39:38 +00:00
"\t${0:# code...}",
"\tbreak;"
],
"description": "Case Block"
},
"$this->…": {
"prefix": "this",
2017-03-10 04:23:15 +00:00
"body": "\\$this->$0;",
2015-11-13 13:39:38 +00:00
"description": "$this->..."
},
"echo $this->…": {
"prefix": "ethis",
2017-03-10 04:23:15 +00:00
"body": "echo \\$this->$0;",
2015-11-13 13:39:38 +00:00
"description": "Echo this"
},
"Throw Exception": {
"prefix": "throw",
"body": [
"throw new $1Exception(${2:\"${3:Error Processing Request}\"}${4:, ${5:1}});",
"$0"
],
"description": "Throw exception"
2017-11-30 11:11:21 +00:00
},
"Region Start": {
"prefix": "#region",
"body": [
"#region"
],
"description": "Folding Region Start"
},
"Region End": {
"prefix": "#endregion",
"body": [
"#endregion"
],
"description": "Folding Region End"
2018-10-04 16:05:24 +00:00
},
"Try Catch Block": {
"prefix": "try",
"body": [
"try {",
"\t${1://code...}",
2018-10-09 13:07:13 +00:00
"} catch (${2:\\Throwable} ${3:$$th}) {",
2018-10-05 09:50:02 +00:00
"\t${4://throw $$th;}",
2018-10-04 16:05:24 +00:00
"}"
],
"description": "Try catch block"
2015-11-13 13:39:38 +00:00
}
}