pulsar/packages/language-php/snippets/language-php.cson
Spiker985 7d0a429fcc
Add escapement to variable literals within snippets
| Name | prefix |
| $GLOBALS[\'…\'] | globals |
| function __construct | con |
| do … while … | do |
| $this->… | this |
| echo $this->… | ethis |
| try … | try |
2023-10-11 14:14:04 -04:00

161 lines
5.7 KiB
Plaintext

'.punctuation.section.embedded.begin.php':
'php … ?>':
'prefix': 'php'
'body': 'php $0 ?>'
'.source.php':
'$GLOBALS[\'…\']':
'prefix': 'globals'
'body': '\\$GLOBALS[\'${1:variable}\']${2: = }${3:something}${4:;}$0'
'?>…<?php':
'prefix': 'php'
'body': '?>$0<?php'
'shorthand echo':
'prefix': '<?'
'body': '<?= $0 ?>'
'function __construct':
'prefix': 'con'
'body': '${1:public }function __construct(${2:${3:Type }$${4:foo} ${5:= ${6:null}}})\n{\n\t${2:\\$this->${4:foo} = $${4:foo};}$0\n}'
'Heredoc':
'prefix': '<<<'
'body': '<<<${1:HTML}\n${2:content here}\n${1:HTML};\n'
'Class Variable':
'prefix': 'doc_v'
'body': '/**\n * ${3:undocumented class variable}\n *\n * @var ${4:string}\n */\n${1:var} $$2;$0'
'PHPDoc function …':
'prefix': 'doc_f'
'body': '/**\n * ${6:undocumented function summary}\n *\n * ${7:Undocumented function long description}\n *\n * @param ${8:type} ${9:var} ${10:Description}\n * @return ${11:return type}\n */\n${1:public }function ${2:FunctionName}(${3:$${4:value}${5:=\'\'}})\n{\n\t${0:// code...}\n}'
'Start Docblock':
'prefix': '/**'
'body': '/**\n * $0\n */'
'class …':
'prefix': 'class'
'body': '/**\n * $1\n */\nclass ${2:ClassName} ${3:extends ${4:AnotherClass}}\n{\n\t$5\n\tfunction ${6:__construct}(${7:argument})\n\t{\n\t\t${0:// code...}\n\t}\n}\n'
'interface …':
'prefix': 'interface'
'body': '/**\n * $1\n */\ninterface ${2:InterfaceName}\n{\n\t${0:// code...}\n}\n'
'trait …':
'prefix': 'trait'
'body': '/**\n * $1\n */\ntrait ${2:TraitName}\n{\n\tfunction ${3:functionName}(${4:argument})\n\t{\n\t\t${5:// code...}\n\t}\n}\n'
'define(…, …)':
'prefix': 'def'
'body': 'define(\'$1\', ${2:\'$3\'});\n$0'
'defined(…)':
'prefix': 'def?'
'body': '$1defined(\'$2\')$0'
'do … while …':
'prefix': 'do'
'body': 'do {\n\t${0:// code...}\n} while (${1:\\$a <= 10});'
'echo "…"':
'prefix': 'echo'
'body': 'echo "${1:string}";$0'
'else …':
'prefix': 'else'
'body': 'else {\n\t${0:// code...}\n}'
'elseif …':
'prefix': 'elseif'
'body': 'elseif (${1:condition}) {\n\t${0:// code...}\n}'
'for …':
'prefix': 'for'
'body': 'for ($${1:i} = ${2:0}; $${1:i} < $3; $${1:i}++) {\n\t${0:// code...}\n}'
'foreach …':
'prefix': 'foreach'
'body': 'foreach ($${1:variable} as $${2:key} ${3:=> $${4:value}}) {\n\t${0:// code...}\n}'
'function …':
'prefix': 'fun'
'body': '${1:public }function ${2:FunctionName}(${3:$${4:value}${5:=\'\'}})\n{\n\t${0:// code...}\n}'
'anonymous function':
'prefix': 'f',
'body': 'function (${1:$${2:value}${3:=\'\'}}) {\n\t${0:// code...}\n}'
'if … else …':
'prefix': 'ifelse'
'body': 'if (${1:condition}) {\n\t${2:// code...}\n} else {\n\t${3:// code...}\n}\n$0'
'if …':
'prefix': 'if'
'body': 'if (${1:condition}) {\n\t${0:// code...}\n}'
'$… = ( … ) ? … : …':
'prefix': 'if?'
'body': '$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b} ;'
'include …':
'prefix': 'incl'
'body': 'include \'${1:file}\';$0'
'include_once …':
'prefix': 'incl1'
'body': 'include_once \'${1:file}\';$0'
'$… = array (…)':
'prefix': 'array'
'body': '$${1:arrayName} = array(\'$2\' => $3${4:,} $0);'
'$… = […]':
'prefix': 'shorray'
'body': '$${1:arrayName} = [\'$2\' => $3${4:,} $0];'
'… => …':
'prefix': 'keyval'
'body': '\'$1\' => $2${3:,} $0'
'require …':
'prefix': 'req'
'body': 'require \'${1:file}\';$0'
'require_once …':
'prefix': 'req1'
'body': 'require_once \'${1:file}\';$0'
'return':
'prefix': 'ret'
'body': 'return$1;$0'
'return false':
'prefix': 'ret0'
'body': 'return false;$0'
'return true':
'prefix': 'ret1'
'body': 'return true;$0'
'switch …':
'prefix': 'switch'
'body': 'switch (${1:variable}) {\n\tcase \'${2:value}\':\n\t\t${3:// code...}\n\t\tbreak;\n\t$0\n\tdefault:\n\t\t${4:// code...}\n\t\tbreak;\n}'
'case …':
'prefix': 'case'
'body': 'case \'${1:variable}\':\n\t${0:// code...}\n\tbreak;'
'$this->…':
'prefix': 'this'
'body': '\\$this->$0'
'echo $this->…':
'prefix': 'ethis'
'body': 'echo \\$this->$0'
'Throw Exception':
'prefix': 'throw'
'body': 'throw new $1\\\\Exception(${2:"${3:Error Processing Request}"}${4:, ${5:1}});\n$0'
'try …':
'prefix': 'try'
'body': 'try {\n\t$0\n} catch (${1:\\\\Exception \\$e}) {\n\t$2\n}\n'
'while …':
'prefix': 'while'
'body': 'while (${1:$a <= 10}) {\n\t${0:// code...}\n}'
'var_dump("…")':
'prefix': 'dump'
'body': 'var_dump($1);$0'
'.text.html.php:not(.source)':
'<?php $this->… ?>':
'prefix': 'this'
'body': '<?php $this->$0 ?>'
'<?php echo $this->… ?>':
'prefix': 'ethis'
'body': '<?php echo $this->$0 ?>'
'.text.html.php':
'<?php … ?>':
'prefix': 'php'
'body': '<?php $0 ?>'
'<?php echo … ?>':
'prefix': 'echo'
'body': '<?php echo ${1:$var} ?>$0'
'<?php echo htmlentities(…) ?>':
'prefix': 'echoh'
'body': '<?php echo htmlentities(${1:$var}, ENT_QUOTES, \'utf-8\'); ?>$0'
'<?php else: ?>':
'prefix': 'else'
'body': '<?php else: ?>'
'<?php foreach (…) … <?php endforeach ?>':
'prefix': 'foreach'
'body': '<?php foreach ($${1:variable} as $${2:key}${3: => $${4:value}}): ?>\n\t${0}\n<?php endforeach; ?>'
'<?php if (…) ?> … <?php else ?> … <?php endif ?>':
'prefix': 'ifelse'
'body': '<?php if (${1:condition}): ?>\n\t$2\n<?php else: ?>\n\t$0\n<?php endif; ?>'
'<?php if (…) ?> … <?php endif ?>':
'prefix': 'if'
'body': '<?php if (${1:condition}): ?>\n\t$0\n<?php endif; ?>'