415 lines
6.6 KiB
Plaintext
415 lines
6.6 KiB
Plaintext
snippet <?
|
|
<?php
|
|
|
|
${0}
|
|
snippet ec
|
|
echo ${0};
|
|
snippet <?e
|
|
<?php echo ${0} ?>
|
|
# this one is for php5.4
|
|
snippet <?=
|
|
<?=${0}?>
|
|
snippet ?=
|
|
<?= ${0} ?>
|
|
snippet ?
|
|
<?php ${0} ?>
|
|
snippet ?f
|
|
<?php foreach ($${1:vars} as $${2:$var}): ?>
|
|
${0}
|
|
<?php endforeach ?>
|
|
snippet ?i
|
|
<?php if ($${1:var}): ?>
|
|
${0}
|
|
<?php endif ?>
|
|
snippet ns
|
|
namespace ${1:Foo\Bar\Baz};
|
|
${0}
|
|
snippet use
|
|
use ${1:Foo\Bar\Baz};
|
|
${0}
|
|
snippet c
|
|
class ${1:`vim_snippets#Filename()`}
|
|
{
|
|
${0}
|
|
}
|
|
snippet i
|
|
interface ${1:`vim_snippets#Filename()`}
|
|
{
|
|
${0}
|
|
}
|
|
snippet t.
|
|
$this->
|
|
snippet f
|
|
function ${1:foo}(${2:array }${3:$bar})
|
|
{
|
|
${0}
|
|
}
|
|
# method
|
|
snippet m
|
|
${1:protected} function ${2:foo}()
|
|
{
|
|
${0}
|
|
}
|
|
# setter method
|
|
snippet sm
|
|
/**
|
|
* Sets the value of ${1:foo}
|
|
*
|
|
* @param ${2:$1} $$1 ${3:description}
|
|
*
|
|
* @return ${4:`vim_snippets#Filename()`}
|
|
*/
|
|
${5:public} function set${6:$2}(${7:$2 }$$1)
|
|
{
|
|
$this->${8:$1} = $$1;
|
|
return $this;
|
|
}
|
|
# getter method
|
|
snippet gm
|
|
/**
|
|
* Gets the value of ${1:foo}
|
|
*
|
|
* @return ${2:$1}
|
|
*/
|
|
${3:public} function get${4:$2}()
|
|
{
|
|
return $this->${5:$1};
|
|
}
|
|
#setter
|
|
snippet $s
|
|
${1:$foo}->set${2:Bar}(${0});
|
|
#getter
|
|
snippet $g
|
|
${1:$foo}->get${0:Bar}();
|
|
|
|
# Tertiary conditional
|
|
snippet =?:
|
|
$${1:foo} = ${2:true} ? ${3:a} : ${0};
|
|
snippet ?:
|
|
${1:true} ? ${2:a} : ${0}
|
|
|
|
snippet C
|
|
$_COOKIE['${1:variable}']
|
|
snippet E
|
|
$_ENV['${1:variable}']
|
|
snippet F
|
|
$_FILES['${1:variable}']
|
|
snippet G
|
|
$_GET['${1:variable}']
|
|
snippet P
|
|
$_POST['${1:variable}']
|
|
snippet R
|
|
$_REQUEST['${1:variable}']
|
|
snippet S
|
|
$_SERVER['${1:variable}']
|
|
snippet SS
|
|
$_SESSION['${1:variable}']
|
|
|
|
# the following are old ones
|
|
snippet inc
|
|
include '${1:file}';
|
|
snippet inc1
|
|
include_once '${1:file}';
|
|
snippet req
|
|
require '${1:file}';
|
|
snippet req1
|
|
require_once '${1:file}';
|
|
# Start Docblock
|
|
snippet /*
|
|
/**
|
|
* ${0}
|
|
*/
|
|
# Class - post doc
|
|
snippet doc_cp
|
|
/**
|
|
* ${1:undocumented class}
|
|
*
|
|
* @package ${2:default}
|
|
* @subpackage ${3:default}
|
|
* @author ${4:`g:snips_author`}
|
|
*/
|
|
# Class Variable - post doc
|
|
snippet doc_vp
|
|
/**
|
|
* ${1:undocumented class variable}
|
|
*
|
|
* @var ${2:string}
|
|
*/
|
|
# Class Variable
|
|
snippet doc_v
|
|
/**
|
|
* ${3:undocumented class variable}
|
|
*
|
|
* @var ${4:string}
|
|
*/
|
|
${1:var} $${2};
|
|
# Class
|
|
snippet doc_c
|
|
/**
|
|
* ${3:undocumented class}
|
|
*
|
|
* @package ${4:default}
|
|
* @subpackage ${5:default}
|
|
* @author ${6:`g:snips_author`}
|
|
*/
|
|
${1:}class ${2:}
|
|
{
|
|
${0}
|
|
} // END $1class $2
|
|
# Constant Definition - post doc
|
|
snippet doc_dp
|
|
/**
|
|
* ${1:undocumented constant}
|
|
*/
|
|
# Constant Definition
|
|
snippet doc_d
|
|
/**
|
|
* ${3:undocumented constant}
|
|
*/
|
|
define(${1}, ${2});
|
|
# Function - post doc
|
|
snippet doc_fp
|
|
/**
|
|
* ${1:undocumented function}
|
|
*
|
|
* @return ${2:void}
|
|
* @author ${3:`g:snips_author`}
|
|
*/
|
|
# Function signature
|
|
snippet doc_s
|
|
/**
|
|
* ${4:undocumented function}
|
|
*
|
|
* @return ${5:void}
|
|
* @author ${6:`g:snips_author`}
|
|
*/
|
|
${1}function ${2}(${3});
|
|
# Function
|
|
snippet doc_f
|
|
/**
|
|
* ${4:undocumented function}
|
|
*
|
|
* @return ${5:void}
|
|
* @author ${6:`g:snips_author`}
|
|
*/
|
|
${1}function ${2}(${3})
|
|
{${0}
|
|
}
|
|
# Header
|
|
snippet doc_h
|
|
/**
|
|
* ${1}
|
|
*
|
|
* @author ${2:`g:snips_author`}
|
|
* @version ${3:$Id$}
|
|
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
|
|
* @package ${0:default}
|
|
*/
|
|
|
|
# Interface
|
|
snippet interface
|
|
/**
|
|
* ${2:undocumented class}
|
|
*
|
|
* @package ${3:default}
|
|
* @author ${4:`g:snips_author`}
|
|
*/
|
|
interface ${1:`vim_snippets#Filename()`}
|
|
{
|
|
${0}
|
|
}
|
|
# class ...
|
|
snippet class
|
|
/**
|
|
* ${1}
|
|
*/
|
|
class ${2:`vim_snippets#Filename()`}
|
|
{
|
|
${3}
|
|
/**
|
|
* ${4}
|
|
*/
|
|
${5:public} function ${6:__construct}(${7:argument})
|
|
{
|
|
${0}
|
|
}
|
|
}
|
|
snippet nc
|
|
namespace ${1:`substitute(substitute(expand("%:h"), '\v^\w+\/(\u)', '\1', ''), '\/', '\\\', 'g')`};
|
|
|
|
${2:abstract }class ${3:`vim_snippets#Filename()`}
|
|
{
|
|
${0}
|
|
}
|
|
# define(...)
|
|
snippet def
|
|
define('${1}'${2});
|
|
# defined(...)
|
|
snippet def?
|
|
${1}defined('${2}')
|
|
snippet wh
|
|
while (${1:/* condition */}) {
|
|
${0}
|
|
}
|
|
# do ... while
|
|
snippet do
|
|
do {
|
|
${0}
|
|
} while (${1:/* condition */});
|
|
snippet if
|
|
if (${1:/* condition */}) {
|
|
${0}
|
|
}
|
|
snippet ifil
|
|
<?php if (${1:/* condition */}): ?>
|
|
${0}
|
|
<?php endif; ?>
|
|
snippet ife
|
|
if (${1:/* condition */}) {
|
|
${2}
|
|
} else {
|
|
${3}
|
|
}
|
|
${0}
|
|
snippet ifeil
|
|
<?php if (${1:/* condition */}): ?>
|
|
${2:<!-- html... -->}
|
|
<?php else: ?>
|
|
${3:<!-- html... -->}
|
|
<?php endif; ?>
|
|
${0}
|
|
snippet el
|
|
else {
|
|
${0}
|
|
}
|
|
snippet eif
|
|
elseif (${1:/* condition */}) {
|
|
${0}
|
|
}
|
|
snippet switch
|
|
switch ($${1:variable}) {
|
|
case '${2:value}':
|
|
${3}
|
|
break;
|
|
${0}
|
|
default:
|
|
${4}
|
|
break;
|
|
}
|
|
snippet case
|
|
case '${1:value}':
|
|
${2}
|
|
break;
|
|
snippet for
|
|
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
|
${0}
|
|
}
|
|
snippet foreach
|
|
foreach ($${1:variable} as $${2:value}) {
|
|
${0}
|
|
}
|
|
snippet foreachil
|
|
<?php foreach ($${1:variable} as $${2:value}): ?>
|
|
${0:<!-- html... -->}
|
|
<?php endforeach; ?>
|
|
snippet foreachk
|
|
foreach ($${1:variable} as $${2:key} => $${3:value}) {
|
|
${0}
|
|
}
|
|
snippet foreachkil
|
|
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
|
|
${0:<!-- html... -->}
|
|
<?php endforeach; ?>
|
|
# $... = array (...)
|
|
snippet array
|
|
$${1:arrayName} = array('${2}' => ${3});
|
|
snippet try
|
|
try {
|
|
${0}
|
|
} catch (${1:Exception} $e) {
|
|
}
|
|
# lambda with closure
|
|
snippet lambda
|
|
${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) {
|
|
${0}
|
|
};
|
|
# pre_dump();
|
|
snippet pd
|
|
echo '<pre>'; var_dump(${0}); echo '</pre>';
|
|
# pre_dump(); die();
|
|
snippet pdd
|
|
echo '<pre>'; var_dump(${1}); echo '</pre>'; die(${0:});
|
|
snippet vd
|
|
var_dump(${0});
|
|
snippet vdd
|
|
var_dump(${1}); die(${0:});
|
|
snippet vdf
|
|
error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');
|
|
snippet http_redirect
|
|
header ("HTTP/1.1 301 Moved Permanently");
|
|
header ("Location: ".URL);
|
|
exit();
|
|
# Getters & Setters
|
|
snippet gs
|
|
/**
|
|
* Gets the value of ${1:foo}
|
|
*
|
|
* @return ${2:$1}
|
|
*/
|
|
public function get${3:$2}()
|
|
{
|
|
return $this->${4:$1};
|
|
}
|
|
|
|
/**
|
|
* Sets the value of $1
|
|
*
|
|
* @param $2 $$1 ${5:description}
|
|
*
|
|
* @return ${6:`vim_snippets#Filename()`}
|
|
*/
|
|
public function set$3(${7:$2 }$$1)
|
|
{
|
|
$this->$4 = $$1;
|
|
return $this;
|
|
}
|
|
# anotation, get, and set, useful for doctrine
|
|
snippet 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;
|
|
}
|
|
snippet rett
|
|
return true;
|
|
snippet retf
|
|
return false;
|
|
snippet am
|
|
$${1:foo} = array_map(function($${2:v}) {
|
|
${0}
|
|
return $$2;
|
|
}, $$1);
|
|
snippet aw
|
|
array_walk($${1:foo}, function(&$${2:v}, $${3:k}) {
|
|
$$2 = ${0};
|
|
});
|
|
|
|
# static var assign once
|
|
snippet static_var
|
|
static $${1} = null;
|
|
if (is_null($$1)){
|
|
$$1 = ${2};
|
|
}
|