vim-snippets/snippets/php.snippets

297 lines
5.0 KiB
Plaintext
Raw Normal View History

2012-07-24 15:02:30 -04:00
snippet ph
<?php
2012-07-24 15:02:30 -04:00
${1}
snippet ec
2012-07-24 15:02:30 -04:00
echo ${1};
snippet ecil
<?php echo ${1} ?>
snippet th
$this->${1:something}
snippet inc
include '${1:file}';${2}
snippet inc1
include_once '${1:file}';${2}
snippet req
require '${1:file}';${2}
snippet req1
require_once '${1:file}';${2}
2012-07-24 15:02:30 -04:00
snippet C
$_COOKIE['${1:variable}']${2}
2012-07-24 15:02:30 -04:00
snippet E
$_ENV['${1:variable}']${2}
2012-07-24 15:02:30 -04:00
snippet F
$_FILES['${1:variable}']${2}
2012-07-24 15:02:30 -04:00
snippet G
$_GET['${1:variable}']${2}
2012-07-24 15:02:30 -04:00
snippet P
$_POST['${1:variable}']${2}
2012-07-24 15:02:30 -04:00
snippet R
$_REQUEST['${1:variable}']${2}
2012-07-24 15:02:30 -04:00
snippet S
$_SERVER['${1:variable}']${2}
2012-07-24 15:02:30 -04:00
snippet SS
$_SESSION['${1:variable}']${2}
# Start Docblock
snippet /*
/**
* ${1}
*/
# Class - post doc
snippet doc_cp
/**
* ${1:undocumented class}
*
* @package ${2:default}
* @subpackage ${3:default}
* @author ${4:`g:snips_author`}
*/${5}
# Class Variable - post doc
snippet doc_vp
/**
* ${1:undocumented class variable}
*
* @var ${2:string}
*/${3}
# Class Variable
snippet doc_v
/**
* ${3:undocumented class variable}
*
* @var ${4:string}
*/
${1:var} $${2};${5}
# Class
snippet doc_c
/**
* ${3:undocumented class}
*
* @package ${4:default}
* @subpackage ${5:default}
* @author ${6:`g:snips_author`}
*/
${1:}class ${2:}
{
${7}
} // END $1class $2
# Constant Definition - post doc
snippet doc_dp
/**
* ${1:undocumented constant}
*/${2}
# Constant Definition
snippet doc_d
/**
* ${3:undocumented constant}
*/
define(${1}, ${2});${4}
# Function - post doc
snippet doc_fp
/**
* ${1:undocumented function}
*
* @return ${2:void}
* @author ${3:`g:snips_author`}
*/${4}
# Function signature
snippet doc_s
/**
* ${4:undocumented function}
*
* @return ${5:void}
* @author ${6:`g:snips_author`}
*/
${1}function ${2}(${3});${7}
# Function
snippet doc_f
/**
* ${4:undocumented function}
*
* @return ${5:void}
* @author ${6:`g:snips_author`}
*/
${1}function ${2}(${3})
{${7}
}
# Header
snippet doc_h
/**
* ${1}
*
* @author ${2:`g:snips_author`}
* @version ${3:$Id$}
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
* @package ${5:default}
*/
# Interface
snippet doc_i
/**
* ${2:undocumented class}
*
* @package ${3:default}
* @author ${4:`g:snips_author`}
*/
interface ${1:}
2012-07-24 15:02:30 -04:00
{
${5}
}$1
# class ...
snippet class
/**
* ${1}
*/
class ${2:ClassName}
{
${3}
2012-07-24 15:02:30 -04:00
${7:public} function ${4:__construct}(${5:argument})
{
${6:// code...}
}
}
# define(...)
snippet def
define('${1}'${2});${3}
# defined(...)
snippet def?
${1}defined('${2}')${3}
snippet wh
while (${1:/* condition */}) {
${2:// code...}
}
# do ... while
snippet do
do {
${2:// code... }
} while (${1:/* condition */});
snippet if
if (${1:/* condition */}) {
${2:// code...}
}
snippet ifil
<?php if (${1:/* condition */}): ?>
${2:<!-- code... -->}
<?php endif; ?>
snippet ife
if (${1:/* condition */}) {
${2:// code...}
} else {
${3:// code...}
}
${4}
snippet ifeil
<?php if (${1:/* condition */}): ?>
${2:<!-- html... -->}
<?php else: ?>
${3:<!-- html... -->}
<?php endif; ?>
${4}
snippet else
else {
${1:// code...}
}
snippet elseif
elseif (${1:/* condition */}) {
${2:// code...}
}
# Tertiary conditional
snippet t
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
snippet switch
switch ($${1:variable}) {
case '${2:value}':
${3:// code...}
break;
${5}
default:
${4:// code...}
break;
}
snippet case
case '${1:value}':
${2:// code...}
break;${3}
snippet for
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4: // code...}
}
snippet foreach
foreach ($${1:variable} as $${2:value}) {
${3:// code...}
}
snippet foreachil
<?php foreach ($${1:variable} as $${2:value}): ?>
${3:<!-- html... -->}
<?php endforeach; ?>
snippet foreachk
foreach ($${1:variable} as $${2:key} => $${3:value}) {
${4:// code...}
}
snippet foreachkil
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
${4:<!-- html... -->}
<?php endforeach; ?>
snippet fun
2012-07-24 15:02:30 -04:00
function ${1:FunctionName}(${2})
{
${3:// code...}
}${4}
snippet p
${1:protected} function ${2:FunctionName}(${3})
{
${4:// code...}
2012-07-24 15:02:30 -04:00
}${5}
# $... = array (...)
snippet array
$${1:arrayName} = array('${2}' => ${3});${4}
snippet try
try {
${2}
} catch (${1:Exception} $e) {
}
# lambda with closure
snippet lambda
${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) {
${4}
};
# pre_dump();
snippet pd
echo '<pre>'; var_dump(${1}); echo '</pre>';
# pre_dump(); die();
snippet pdd
echo '<pre>'; var_dump(${1}); echo '</pre>'; die(${2:});
snippet vd
var_dump(${1});
2011-11-24 03:43:32 -05:00
snippet vdd
var_dump(${1}); die(${2:});
snippet http_redirect
header ("HTTP/1.1 301 Moved Permanently");
header ("Location: ".URL);
exit();
# Getters & Setters
snippet getset
/**
2011-12-22 10:40:48 -05:00
* Gets the value of ${1:}
*
* @return ${2}
*/
2012-07-24 15:02:30 -04:00
public function get$1()
{
2012-07-24 15:02:30 -04:00
return $this->$1;
}
/**
2011-12-22 10:40:48 -05:00
* Sets the value of $1
*
2011-12-22 10:40:48 -05:00
* @param mixed $$1 ${3}
*/
2012-07-24 15:02:30 -04:00
public function set$1($$1)
{
2012-07-24 15:02:30 -04:00
$this->$1 = $$1;
return $this;
}
2012-04-08 17:26:04 -04:00
snippet rett
return true;
snippet retf
return false;