2015-11-13 13:39:38 +00:00
|
|
|
{
|
2023-05-18 21:46:36 +00:00
|
|
|
"$… = ( … ) ? … : …": {
|
|
|
|
"prefix": "if?",
|
|
|
|
"body": "$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b} ;",
|
|
|
|
"description": "Ternary conditional assignment"
|
2017-03-10 04:23:15 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"$… = array (…)": {
|
|
|
|
"prefix": "array",
|
|
|
|
"body": "$${1:arrayName} = array($0);",
|
|
|
|
"description": "Array initializer"
|
|
|
|
},
|
|
|
|
"$… = […]": {
|
|
|
|
"prefix": "shorray",
|
|
|
|
"body": "$${1:arrayName} = [$0];",
|
|
|
|
"description": "Array initializer"
|
|
|
|
},
|
|
|
|
"… => …": {
|
|
|
|
"prefix": "keyval,kvp",
|
|
|
|
"body": "'$1' => $2$0",
|
|
|
|
"description": "Key-Value pair"
|
|
|
|
},
|
|
|
|
"$a <=> $b": {
|
|
|
|
"prefix": "spaceship",
|
2023-09-06 00:13:03 +00:00
|
|
|
"body": "(${1:\\$a} <=> ${2:\\$b} === ${3|0,1,-1|})",
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Spaceship equality check"
|
|
|
|
},
|
|
|
|
"attribute": {
|
|
|
|
"prefix": "attr",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"#[\\\\Attribute]",
|
|
|
|
"class ${1:My}Attribute${2: extends ${3:MyOther}Attribute} {",
|
2017-03-10 04:23:15 +00:00
|
|
|
"\t$0",
|
2023-05-18 21:46:36 +00:00
|
|
|
"}"
|
2015-11-13 13:39:38 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Attribute"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"attribute target": {
|
|
|
|
"prefix": "attr_target",
|
|
|
|
"body": "\\Attribute::${1|TARGET_ALL,TARGET_CLASS,TARGET_FUNCTION,TARGET_METHOD,TARGET_PROPERTY,TARGET_CLASS_CONSTANT,TARGET_PARAMETER,IS_REPEATABLE|}$0"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"attribute with target": {
|
|
|
|
"prefix": "attr_with_target",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"#[\\\\Attribute(\\Attribute::${1|TARGET_ALL,TARGET_CLASS,TARGET_FUNCTION,TARGET_METHOD,TARGET_PROPERTY,TARGET_CLASS_CONSTANT,TARGET_PARAMETER,IS_REPEATABLE|}$2)]",
|
|
|
|
"class ${3:My}Attribute${4: extends ${5:MyOther}Attribute} {",
|
|
|
|
"\t$0",
|
|
|
|
"}"
|
2015-11-13 13:39:38 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Attribute - Chain targets with attr_target snippet"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"case …": {
|
|
|
|
"prefix": "case",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"case '${1:value}':",
|
2015-11-13 13:39:38 +00:00
|
|
|
"\t${0:# code...}",
|
2023-05-18 21:46:36 +00:00
|
|
|
"\tbreak;"
|
2015-11-13 13:39:38 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Case Block"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"class …": {
|
|
|
|
"prefix": "class",
|
2017-03-10 04:23:15 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"${1:${2|final ,readonly |}}class ${3:${TM_FILENAME_BASE}}${4: extends ${5:AnotherClass}} ${6:implements ${7:Interface}}",
|
|
|
|
"{",
|
|
|
|
"\t$0",
|
|
|
|
"}",
|
|
|
|
""
|
2017-03-10 04:23:15 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Class definition"
|
2017-03-10 04:23:15 +00:00
|
|
|
},
|
2023-05-19 00:17:56 +00:00
|
|
|
"class __construct": {
|
|
|
|
"prefix": "construct",
|
|
|
|
"body": [
|
|
|
|
"${1|public,private,protected|} function __construct(${2:${3:Type} $${4:var}${5: = ${6:null}}}$7) {",
|
|
|
|
"\t\\$this->${4:var} = $${4:var};$0",
|
|
|
|
"}"
|
|
|
|
]
|
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"class function …": {
|
|
|
|
"prefix": "class_fun",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"${1|public ,private ,protected |}${2: static }function ${3:FunctionName}(${4:${5:${6:Type} }$${7:var}${8: = ${9:null}}}$10) : ${11:Returntype}",
|
2015-11-13 13:39:38 +00:00
|
|
|
"{",
|
|
|
|
"\t${0:# code...}",
|
|
|
|
"}"
|
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Function for classes, traits and enums"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"const": {
|
|
|
|
"prefix": "const",
|
|
|
|
"body": "${1|public ,private ,protected |}const ${2:NAME} = $3;",
|
|
|
|
"description": "Constant for classes, traits, enums"
|
|
|
|
},
|
|
|
|
"enum": {
|
|
|
|
"prefix": "enum",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"enum $1 {",
|
|
|
|
"\tcase $2;$0",
|
|
|
|
"}"
|
|
|
|
]
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
|
|
|
"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"
|
|
|
|
},
|
2023-05-19 00:17:56 +00:00
|
|
|
"else …": {
|
|
|
|
"prefix": "else",
|
|
|
|
"body": [
|
|
|
|
"else {",
|
|
|
|
"\t${0:# code...}",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Else block"
|
|
|
|
},
|
|
|
|
"elseif …": {
|
|
|
|
"prefix": "elseif",
|
|
|
|
"body": [
|
|
|
|
"elseif (${1:condition}) {",
|
|
|
|
"\t${0:# code...}",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Elseif block"
|
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"for …": {
|
|
|
|
"prefix": "for",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"for ($${1:i}=${2:0}; $${1:i} < $3; $${1:i}++) { ",
|
2017-03-10 04:23:15 +00:00
|
|
|
"\t${0:# code...}",
|
|
|
|
"}"
|
2015-11-13 13:39:38 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "For-loop"
|
|
|
|
},
|
|
|
|
"foreach …": {
|
|
|
|
"prefix": "foreach",
|
|
|
|
"body": [
|
|
|
|
"foreach ($${1:variable} as $${2:key}${3: => $${4:value}}) {",
|
|
|
|
"\t${0:# code...}",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Foreach loop"
|
|
|
|
},
|
|
|
|
"function": {
|
|
|
|
"prefix": "fun",
|
|
|
|
"body": [
|
|
|
|
"function ${1:FunctionName}($2)${3: : ${4:Returntype}} {",
|
|
|
|
"\t$0",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Function - use param snippet for parameters"
|
|
|
|
},
|
|
|
|
"anonymous function": {
|
|
|
|
"prefix": "fun_anonymous",
|
|
|
|
"body": [
|
|
|
|
"function ($1)${2: use ($${3:var})} {",
|
|
|
|
"\t$0",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Anonymous Function"
|
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"
|
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"match": {
|
|
|
|
"prefix": "match",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"match (${1:expression}) {",
|
|
|
|
"\t$2 => $3,",
|
|
|
|
"\t$4 => $5,$0",
|
2015-11-13 13:39:38 +00:00
|
|
|
"}"
|
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Match expression; like switch with identity checks. Use keyval snippet to chain expressions"
|
|
|
|
},
|
|
|
|
"param": {
|
|
|
|
"prefix": "param",
|
|
|
|
"body": "${1:Type} $${2:var}${3: = ${4:null}}$5",
|
|
|
|
"description": "Parameter definition"
|
|
|
|
},
|
|
|
|
"property": {
|
|
|
|
"prefix": "property",
|
|
|
|
"body": "${1|public ,private ,protected |}${2|static ,readonly |}${3:Type} $${4:var}${5: = ${6:null}};$0",
|
|
|
|
"description": "Property"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"PHPDoc class …": {
|
|
|
|
"prefix": "doc_class",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"/**",
|
|
|
|
" * ${8:undocumented class}",
|
|
|
|
" */",
|
|
|
|
"${1:${2|final ,readonly |}}class ${3:${TM_FILENAME_BASE}}${4: extends ${5:AnotherClass}} ${6:implements ${7:Interface}}",
|
|
|
|
"{",
|
|
|
|
"\t$0",
|
|
|
|
"}",
|
|
|
|
""
|
2015-11-13 13:39:38 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Documented Class Declaration"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"PHPDoc function …": {
|
|
|
|
"prefix": "doc_fun",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"/**",
|
|
|
|
" * ${1:undocumented function summary}",
|
|
|
|
" *",
|
|
|
|
" * ${2:Undocumented function long description}",
|
|
|
|
" *",
|
|
|
|
"${3: * @param ${4:Type} $${5:var} ${6:Description}}",
|
|
|
|
"${7: * @return ${8:type}}",
|
|
|
|
"${9: * @throws ${10:conditon}}",
|
|
|
|
" **/",
|
|
|
|
"${11:public }function ${12:FunctionName}(${13:${14:${4:Type} }$${5:var}${15: = ${16:null}}}17)",
|
|
|
|
"{",
|
2015-11-13 13:39:38 +00:00
|
|
|
"\t${0:# code...}",
|
|
|
|
"}"
|
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Documented function"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"PHPDoc param …": {
|
|
|
|
"prefix": "doc_param",
|
2015-11-13 13:39:38 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"* @param ${1:Type} ${2:var} ${3:Description}$0"
|
2015-11-13 13:39:38 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Paramater documentation"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"PHPDoc trait": {
|
|
|
|
"prefix": "doc_trait",
|
|
|
|
"body": [
|
|
|
|
"/**",
|
|
|
|
" * $1",
|
|
|
|
" */",
|
|
|
|
"trait ${2:TraitName}",
|
|
|
|
"{",
|
|
|
|
"\t$0",
|
|
|
|
"}",
|
|
|
|
""
|
|
|
|
],
|
|
|
|
"description": "Trait"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"PHPDoc var": {
|
|
|
|
"prefix": "doc_var",
|
|
|
|
"body": [
|
|
|
|
"/** @var ${1:Type} $${2:var} ${3:description} */",
|
|
|
|
"${4:protected} $${2:var}${5: = ${6:null}};$0"
|
|
|
|
],
|
|
|
|
"description": "Documented Class Variable"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"Region End": {
|
|
|
|
"prefix": "#endregion",
|
|
|
|
"body": [
|
|
|
|
"#endregion"
|
|
|
|
],
|
|
|
|
"description": "Folding Region End"
|
|
|
|
},
|
|
|
|
"Region Start": {
|
|
|
|
"prefix": "#region",
|
|
|
|
"body": [
|
|
|
|
"#region"
|
|
|
|
],
|
|
|
|
"description": "Folding Region Start"
|
2015-11-13 13:39:38 +00:00
|
|
|
},
|
|
|
|
"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"
|
|
|
|
},
|
2023-05-19 00:17:56 +00:00
|
|
|
"$this->…": {
|
|
|
|
"prefix": "this",
|
|
|
|
"body": "\\$this->$0;",
|
|
|
|
"description": "$this->..."
|
|
|
|
},
|
|
|
|
"Throw Exception": {
|
|
|
|
"prefix": "throw",
|
|
|
|
"body": [
|
|
|
|
"throw new $1Exception(${2:\"${3:Error Processing Request}\"}${4:, ${5:1}});",
|
|
|
|
"$0"
|
|
|
|
],
|
|
|
|
"description": "Throw exception"
|
|
|
|
},
|
2023-05-18 21:46:36 +00:00
|
|
|
"trait …": {
|
|
|
|
"prefix": "trait",
|
2017-11-30 11:11:21 +00:00
|
|
|
"body": [
|
2023-05-18 21:46:36 +00:00
|
|
|
"trait ${1:TraitName}",
|
|
|
|
"{",
|
|
|
|
"\t$0",
|
|
|
|
"}",
|
|
|
|
""
|
2017-11-30 11:11:21 +00:00
|
|
|
],
|
2023-05-18 21:46:36 +00:00
|
|
|
"description": "Trait"
|
2018-10-04 16:05:24 +00:00
|
|
|
},
|
|
|
|
"Try Catch Block": {
|
|
|
|
"prefix": "try",
|
|
|
|
"body": [
|
|
|
|
"try {",
|
|
|
|
"\t${1://code...}",
|
2019-03-27 21:42:52 +00:00
|
|
|
"} catch (${2:\\Throwable} ${3:\\$th}) {",
|
|
|
|
"\t${4://throw \\$th;}",
|
2018-10-04 16:05:24 +00:00
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Try catch block"
|
2023-05-18 21:46:36 +00:00
|
|
|
},
|
|
|
|
"use function": {
|
|
|
|
"prefix": "use_fun",
|
|
|
|
"body": "use function $1;"
|
|
|
|
},
|
|
|
|
"use const": {
|
|
|
|
"prefix": "use_const",
|
|
|
|
"body": "use const $1;"
|
|
|
|
},
|
|
|
|
"use grouping": {
|
|
|
|
"prefix": "use_group",
|
|
|
|
"body": [
|
|
|
|
"use${1| const , function |}$2\\{",
|
|
|
|
"\t$0,",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "Use grouping imports"
|
|
|
|
},
|
|
|
|
"use as ": {
|
|
|
|
"prefix": "use_as",
|
|
|
|
"body": "use${1| const , function |}$2 as $3;",
|
|
|
|
"description": "Use as alias"
|
|
|
|
},
|
|
|
|
"while …": {
|
|
|
|
"prefix": "while",
|
|
|
|
"body": [
|
|
|
|
"while (${1:$${2:a} <= ${3:10}}) {",
|
|
|
|
"\t${0:# code...}",
|
|
|
|
"}"
|
|
|
|
],
|
|
|
|
"description": "While-loop"
|
2015-11-13 13:39:38 +00:00
|
|
|
}
|
2020-04-08 08:12:17 +00:00
|
|
|
}
|