vimrc/sources_non_forked/vim-snippets/UltiSnips/php.snippets

356 lines
5.8 KiB
Text
Raw Normal View History

priority -50
## Snippets from SnipMate, taken from
## https://github.com/scrooloose/snipmate-snippets.git
snippet array "array"
$${1:arrayName} = array('${2}' => ${3});${4}
endsnippet
snippet def "def"
2015-07-13 10:22:46 +00:00
define('${1:VARIABLE_NAME}', ${2:'definition'});${3}
endsnippet
snippet do "do"
do {
${2:// code... }
2014-09-27 15:32:18 +00:00
} while (${1:/* condition */});
endsnippet
snippet doc_f "doc_f"
/**
* $2
* @return ${4:void}
* @author ${5:`!v g:snips_author`}
**/
${1:public }function ${2:someFunc}(${3})
{${6}
}
endsnippet
snippet doc_i "doc_i"
2013-08-03 12:50:12 +00:00
/**
* $1
* @package ${2:default}
* @author ${3:`!v g:snips_author`}
**/
interface ${1:someClass}
{${4}
} // END interface $1"
endsnippet
snippet else "else"
else {
${1:// code...}
}
endsnippet
snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:// code...}
}
endsnippet
snippet foreachk "foreachk"
2015-07-13 10:22:46 +00:00
foreach ($${1:variable} as $${2:key} => $${3:value}) {
${4:// code...}
}
endsnippet
snippet get "get"
$_GET['${1}']${2}
endsnippet
snippet if "if"
if (${1:/* condition */}) {
${2:// code...}
}
endsnippet
2014-09-27 15:32:18 +00:00
snippet elif "elseif"
elseif (${1:/* condition */}) {
${2:// code...}
}
endsnippet
snippet inc "inc"
include '${1:file}';${2}
endsnippet
snippet log "log"
error_log(var_export(${1}, true));${2}
endsnippet
snippet post "post"
$_POST['${1}']${2}
endsnippet
2015-07-13 10:22:46 +00:00
snippet req "req1"
require_once '${1:file}';${2}
endsnippet
snippet req1 "req1"
require_once '${1:file}';${2}
endsnippet
snippet session "session"
$_SESSION['${1}']${2}
endsnippet
snippet t "t"
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
endsnippet
snippet var "var"
var_export(${1});${2}
endsnippet
snippet getter "PHP Class Getter" b
2015-02-04 10:43:54 +00:00
/**
* Getter for $1
2015-02-04 10:43:54 +00:00
*
* ${2:return string}
*/
public function get${1/\w+\s*/\u$0/}()
{
2015-02-04 10:43:54 +00:00
return $this->$1;$3
}
endsnippet
snippet setter "PHP Class Setter" b
2015-02-04 10:43:54 +00:00
/**
* Setter for $1
2015-02-04 10:43:54 +00:00
*
* @param ${2:string} $$1
* @return ${3:`!p snip.rv=snip.basename`}
*/
2015-02-04 10:43:54 +00:00
public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1)
{
2015-02-04 10:43:54 +00:00
$this->$1 = $$1;$5
2015-07-13 10:22:46 +00:00
2015-02-04 10:43:54 +00:00
${6:return $this;}
}
$0
endsnippet
snippet gs "PHP Class Getter Setter" b
2015-02-04 10:43:54 +00:00
/**
2014-04-18 12:58:02 +00:00
* Getter for $1
2015-02-04 10:43:54 +00:00
*
* return ${2:string}
*/
2014-04-18 12:58:02 +00:00
public function get${1/\w+\s*/\u$0/}()
{
2015-02-04 10:43:54 +00:00
return $this->$1;$3
}
2015-02-04 10:43:54 +00:00
/**
2014-04-18 12:58:02 +00:00
* Setter for $1
2015-02-04 10:43:54 +00:00
*
* @param $2 $$1
* @return ${4:`!p snip.rv=snip.basename`}
2013-08-03 12:50:12 +00:00
*/
2015-02-04 10:43:54 +00:00
public function set${1/\w+\s*/\u$0/}(${5:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1)
{
2015-02-04 10:43:54 +00:00
$this->$1 = $$1;$6
2015-07-13 10:22:46 +00:00
2015-02-04 10:43:54 +00:00
${7:return $this;}
}
$0
endsnippet
snippet pub "Public function" b
/**
* ${3:undocumented function}
*
* @return ${4:void}
*/
public function ${1:name}(${2:$param})
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pro "Protected function" b
/**
* ${3:undocumented function}
*
* @return ${4:void}
*/
protected function ${1:name}(${2:$param})
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pri "Private function" b
/**
* ${3:undocumented function}
*
* @return ${4:void}
*/
private function ${1:name}(${2:$param})
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pubs "Public static function" b
/**
* ${3:undocumented function}
*
* @return ${4:void}
*/
public static function ${1:name}(${2:$param})
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pros "Protected static function" b
/**
* ${3:undocumented function}
*
* @return ${4:void}
*/
protected static function ${1:name}(${2:$param})
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pris "Private static function" b
/**
* ${3:undocumented function}
*
* @return ${4:void}
*/
private static function ${1:name}(${2:$param})
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet fu "Function snip" b
function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet fore "Foreach loop"
2015-07-13 10:22:46 +00:00
foreach ($${1:variable} as $${3:value}) {
${VISUAL}${4}
}
$0
endsnippet
snippet new "New class instance" b
2015-07-13 10:22:46 +00:00
$${1:variableName} = new ${2:${1/\w+\s*/\u$0/}}($3);
$0
endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
} else {
${3:// code...}
}
$0
endsnippet
snippet ns "namespace declaration" b
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
2015-02-24 10:45:22 +00:00
snip.rv = m.group().replace('/', '\\')
`};
endsnippet
snippet class "Class declaration template" b
<?php
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
2015-02-24 10:45:22 +00:00
snip.rv = m.group().replace('/', '\\')
`};
/**
* Class ${1:`!p snip.rv=snip.basename`}
* @author ${2:`!v g:snips_author`}
*/
class $1
{
}
endsnippet
snippet interface "Interface declaration template" b
<?php
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
2015-02-24 10:45:22 +00:00
snip.rv = m.group().replace('/', '\\')
`};
/**
* Interface ${1:`!p snip.rv=snip.basename`}
* @author ${2:`!v g:snips_author`}
*/
interface $1
{
2015-02-24 10:45:22 +00:00
public function ${3:someFunction}();$4
}
endsnippet
snippet construct "__construct()" b
/**
* @param $2mixed ${1/, /\n * \@param mixed /g}
*/
public function __construct(${1:$dependencies})
{${1/\$(\w+)(, )*/\n $this->$1 = $$1;/g}
}
$0
endsnippet
2014-09-27 15:32:18 +00:00
snippet ve "Dumb debug helper in HTML"
echo '<pre>' . var_export($1, 1) . '</pre>';$0
endsnippet
snippet pc "Dumb debug helper in cli"
var_export($1);$0
endsnippet
# Symfony 2 based snippets
snippet sfa "Symfony 2 Controller action"
/**
* @Route("/${1:route_name}", name="$1")
* @Template()
*/
public function $1Action($2)
{
$3
return ${4:array();}$0
}
endsnippet
snippet inheritdoc "@inheritdoc docblock"
/**
* {@inheritdoc}
*/
endsnippet
# :vim:ft=snippets: