Skip to content

Commit

Permalink
converted snipmate php snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
darookee committed Sep 25, 2013
1 parent 5076d2b commit fec8e29
Showing 1 changed file with 397 additions and 0 deletions.
397 changes: 397 additions & 0 deletions UltiSnips/php/converted_from_snipmate.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,397 @@
snippet ec "ec"
echo ${0};
endsnippet

snippet <?e "<?e"
<?php echo ${0} ?>
endsnippet

# this one is for php5.4
snippet <?= "<?="
<?=${0}?>
endsnippet

snippet ? "?"
<?php ${0} ?>
endsnippet

snippet ?f "?f"
<?php foreach ($${1:vars} as $${2:$var}): ?>
${0}
<?php endforeach ?>
endsnippet

snippet ?i "?i"
<?php if ($${1:var}): ?>
${0}
<?php endif ?>
endsnippet

snippet t. "t."
$this->
endsnippet

snippet f "f"
function ${1:foo}(${2:array }${3:$bar})
{
${0}
}
endsnippet

# method
snippet m "m"
${1:protected} function ${2:foo}()
{
${0}
}
endsnippet

# Tertiary conditional
snippet =?: "=?:"
$${1:foo} = ${2:true} ? ${3:a} : ${0};
endsnippet

snippet ?: "?:"
${1:true} ? ${2:a} : ${0}
endsnippet

# Class - post doc
snippet doc_cp "doc_cp"
/**
* ${1:undocumented class}
*
* @package ${2:default}
* @subpackage ${3:default}
* @author ${4:`!v g:snips_author`}
*/
endsnippet

# Class Variable - post doc
snippet doc_vp "doc_vp"
/**
* ${1:undocumented class variable}
*
* @var ${2:string}
*/
endsnippet

# Class Variable
snippet doc_v "doc_v"
/**
* ${3:undocumented class variable}
*
* @var ${4:string}
*/
${1:var} $${2};
endsnippet

# Class
snippet doc_c "doc_c"
/**
* ${3:undocumented class}
*
* @package ${4:default}
* @subpackage ${5:default}
* @author ${6:`!v g:snips_author`}
*/
${1:}class ${2:}
{
${0}
} // END $1class $2
endsnippet

# Constant Definition - post doc
snippet doc_dp "doc_dp"
/**
* ${1:undocumented constant}
*/
endsnippet

# Constant Definition
snippet doc_d "doc_d"
/**
* ${3:undocumented constant}
*/
define(${1}, ${2});
endsnippet

# Function - post doc
snippet doc_fp "doc_fp"
/**
* ${1:undocumented function}
*
* @return ${2:void}
* @author ${3:`!v g:snips_author`}
*/
endsnippet

# Function signature
snippet doc_s "doc_s"
/**
* ${4:undocumented function}
*
* @return ${5:void}
* @author ${6:`!v g:snips_author`}
*/
${1}function ${2}(${3});
endsnippet

# Function
snippet doc_f "doc_f"
/**
* ${4:undocumented function}
*
* @return ${5:void}
* @author ${6:`!v g:snips_author`}
*/
${1}function ${2}(${3})
{${0}
}
endsnippet

# Header
snippet doc_h "doc_h"
/**
* ${1}
*
* @author ${2:`!v g:snips_author`}
* @version ${3:$Id$}
* @copyright ${4:$2}, `!v strftime('%d %B, %Y')`
* @package ${0:default}
*/
endsnippet

# Interface
snippet interface "interface"
/**
* ${2:undocumented class}
*
* @package ${3:default}
* @author ${4:`!v g:snips_author`}
*/
interface ${1:`!v vim_snippets#Filename()`}
{
${0}
}
endsnippet

# class ...
snippet class "class"
/**
* ${1}
*/
class ${2:`!v vim_snippets#Filename()`}
{
${3}
/**
* ${4}
*/
${5:public} function ${6:__construct}(${7:argument})
{
${0}
}
}
endsnippet

snippet nc "nc"
namespace ${1:`!v substitute(substitute(expand("%:h"), '\v^\w+\/(\u)', '\1', ''), '\/', '\\\', 'g')`};
${2:abstract }class ${3:`!v vim_snippets#Filename()`}
{
${0}
}
endsnippet

# define(...)
snippet def "def"
define('${1}'${2});
endsnippet

# defined(...)
snippet def? "def?"
${1}defined('${2}')
endsnippet

snippet wh "wh"
while (${1:/* condition */}) {
${0}
}
endsnippet

# do ... while
snippet do "do"
do {
${0}
} while (${1:/* condition */});
endsnippet

snippet ifil "ifil"
<?php if (${1:/* condition */}): ?>
${0}
<?php endif; ?>
endsnippet

snippet ifeil "ifeil"
<?php if (${1:/* condition */}): ?>
${2:<!-- html... -->}
<?php else: ?>
${3:<!-- html... -->}
<?php endif; ?>
${0}
endsnippet

snippet el "el"
else {
${0}
}
endsnippet

snippet eif "eif"
elseif (${1:/* condition */}) {
${0}
}
endsnippet

snippet switch "switch"
switch ($${1:variable}) {
case '${2:value}':
${3}
break;
${0}
default:
${4}
break;
}
endsnippet

snippet case "case"
case '${1:value}':
${2}
break;
endsnippet

snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${0}
}
endsnippet

snippet foreach "foreach"
foreach ($${1:variable} as $${2:value}) {
${0}
}
endsnippet

snippet foreachil "foreachil"
<?php foreach ($${1:variable} as $${2:value}): ?>
${0:<!-- html... -->}
<?php endforeach; ?>
endsnippet

snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}) {
${0}
}
endsnippet

snippet foreachkil "foreachkil"
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
${0:<!-- html... -->}
<?php endforeach; ?>
endsnippet

# $... = array (...)
snippet array "array"
$${1:arrayName} = array('${2}' => ${3});
endsnippet

snippet try "try"
try {
${0}
} catch (${1:Exception} $e) {
}
endsnippet

# lambda with closure
snippet lambda "lambda"
${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) {
${0}
};
endsnippet

# pre_dump();
snippet pd "pd"
echo '<pre>'; var_dump(${0}); echo '</pre>';
endsnippet

# pre_dump(); die();
snippet pdd "pdd"
echo '<pre>'; var_dump(${1}); echo '</pre>'; die(${0:});
endsnippet

snippet vd "vd"
var_dump(${0});
endsnippet

snippet vdd "vdd"
var_dump(${1}); die(${0:});
endsnippet

snippet vdf "vdf"
error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');
endsnippet

snippet http_redirect "http_redirect"
header ("HTTP/1.1 301 Moved Permanently");
header ("Location: ".URL);
exit();
endsnippet

# anotation, get, and set, useful for doctrine
snippet ags "ags"
/**
* ${1:description}
*
* @${0}
*/
${2:protected} $${3:foo};
public function get${4:$3}()
{
return $this->$3;
}
public function set$4(${5:$4 }$${6:$3})
{
$this->$3 = $$6;
return $this;
}
endsnippet

snippet rett "rett"
return true;
endsnippet

snippet retf "retf"
return false;
endsnippet

snippet am "am"
$${1:foo} = array_map(function($${2:v}) {
${0}
return $$2;
}, $$1);
endsnippet

snippet aw "aw"
array_walk($${1:foo}, function(&$${2:v}, $${3:k}) {
$$2 = ${0};
});
endsnippet

# static var assign once
snippet static_var "static_var"
static $${1} = null;
if (is_null($$1)){
$$1 = ${2};
}
endsnippet


0 comments on commit fec8e29

Please sign in to comment.