2012-07-25 00:09:06 -04:00
|
|
|
snippet <?
|
2011-06-20 13:40:28 -04:00
|
|
|
<?php
|
2012-07-24 15:02:30 -04:00
|
|
|
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet ec
|
2013-07-25 17:17:32 -04:00
|
|
|
echo ${0};
|
2012-07-25 00:09:06 -04:00
|
|
|
snippet <?e
|
2013-07-25 17:17:32 -04:00
|
|
|
<?php echo ${0} ?>
|
2012-07-27 07:40:14 -04:00
|
|
|
# this one is for php5.4
|
2012-07-25 00:09:06 -04:00
|
|
|
snippet <?=
|
2013-07-25 17:17:32 -04:00
|
|
|
<?=${0}?>
|
2013-04-16 17:44:48 -04:00
|
|
|
snippet ?=
|
2013-07-25 17:17:32 -04:00
|
|
|
<?= ${0} ?>
|
2013-04-16 17:44:48 -04:00
|
|
|
snippet ?
|
2013-07-25 17:17:32 -04:00
|
|
|
<?php ${0} ?>
|
2013-04-16 17:44:48 -04:00
|
|
|
snippet ?f
|
2013-04-16 17:52:43 -04:00
|
|
|
<?php foreach ($${1:vars} as $${2:$var}): ?>
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2013-04-16 17:44:48 -04:00
|
|
|
<?php endforeach ?>
|
|
|
|
snippet ?i
|
2013-04-16 17:52:43 -04:00
|
|
|
<?php if ($${1:var}): ?>
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2013-04-16 17:44:48 -04:00
|
|
|
<?php endif ?>
|
2012-07-27 07:40:14 -04:00
|
|
|
snippet ns
|
|
|
|
namespace ${1:Foo\Bar\Baz};
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-27 07:40:14 -04:00
|
|
|
snippet use
|
|
|
|
use ${1:Foo\Bar\Baz};
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-27 07:40:14 -04:00
|
|
|
snippet c
|
2013-07-07 21:41:11 -04:00
|
|
|
class ${1:`vim_snippets#Filename()`}
|
2012-07-27 07:40:14 -04:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-27 07:40:14 -04:00
|
|
|
}
|
|
|
|
snippet i
|
2013-07-07 21:41:11 -04:00
|
|
|
interface ${1:`vim_snippets#Filename()`}
|
2012-07-27 07:40:14 -04:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-27 07:40:14 -04:00
|
|
|
}
|
2012-07-30 11:09:36 -04:00
|
|
|
snippet t.
|
2013-07-25 17:17:32 -04:00
|
|
|
$this->
|
2012-07-27 07:40:14 -04:00
|
|
|
snippet f
|
2014-07-01 14:35:16 -04:00
|
|
|
function ${1}(${3})
|
2012-07-27 07:40:14 -04:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-27 07:40:14 -04:00
|
|
|
}
|
|
|
|
# method
|
|
|
|
snippet m
|
2013-04-11 21:16:52 -04:00
|
|
|
${1:protected} function ${2:foo}()
|
2012-07-27 07:40:14 -04:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-27 07:40:14 -04:00
|
|
|
}
|
|
|
|
# setter method
|
2013-04-11 21:18:57 -04:00
|
|
|
snippet sm
|
2012-12-03 11:18:40 -05:00
|
|
|
/**
|
|
|
|
* Sets the value of ${1:foo}
|
|
|
|
*
|
|
|
|
* @param ${2:$1} $$1 ${3:description}
|
|
|
|
*
|
2013-07-07 21:41:11 -04:00
|
|
|
* @return ${4:`vim_snippets#Filename()`}
|
2012-12-03 11:18:40 -05:00
|
|
|
*/
|
|
|
|
${5:public} function set${6:$2}(${7:$2 }$$1)
|
2012-07-27 07:40:14 -04:00
|
|
|
{
|
2012-12-03 11:18:40 -05:00
|
|
|
$this->${8:$1} = $$1;
|
2012-07-27 07:40:14 -04:00
|
|
|
return $this;
|
2013-07-25 17:17:32 -04:00
|
|
|
}
|
2012-07-27 07:40:14 -04:00
|
|
|
# getter method
|
|
|
|
snippet gm
|
2012-12-03 11:18:40 -05:00
|
|
|
/**
|
|
|
|
* Gets the value of ${1:foo}
|
|
|
|
*
|
|
|
|
* @return ${2:$1}
|
|
|
|
*/
|
|
|
|
${3:public} function get${4:$2}()
|
2012-07-27 07:40:14 -04:00
|
|
|
{
|
2012-12-03 11:18:40 -05:00
|
|
|
return $this->${5:$1};
|
2013-07-25 17:17:32 -04:00
|
|
|
}
|
2012-07-30 04:19:03 -04:00
|
|
|
#setter
|
|
|
|
snippet $s
|
2013-07-25 17:17:32 -04:00
|
|
|
${1:$foo}->set${2:Bar}(${0});
|
2012-07-30 04:19:03 -04:00
|
|
|
#getter
|
|
|
|
snippet $g
|
2013-07-25 17:17:32 -04:00
|
|
|
${1:$foo}->get${0:Bar}();
|
2012-07-30 11:09:36 -04:00
|
|
|
|
|
|
|
# Tertiary conditional
|
|
|
|
snippet =?:
|
2013-07-25 17:17:32 -04:00
|
|
|
$${1:foo} = ${2:true} ? ${3:a} : ${0};
|
2012-07-30 11:09:36 -04:00
|
|
|
snippet ?:
|
2013-07-25 17:17:32 -04:00
|
|
|
${1:true} ? ${2:a} : ${0}
|
2012-07-30 11:09:36 -04:00
|
|
|
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet C
|
2013-07-25 17:17:32 -04:00
|
|
|
$_COOKIE['${1:variable}']
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet E
|
2013-07-25 17:17:32 -04:00
|
|
|
$_ENV['${1:variable}']
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet F
|
2013-07-25 17:17:32 -04:00
|
|
|
$_FILES['${1:variable}']
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet G
|
2013-07-25 17:17:32 -04:00
|
|
|
$_GET['${1:variable}']
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet P
|
2013-07-25 17:17:32 -04:00
|
|
|
$_POST['${1:variable}']
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet R
|
2013-07-25 17:17:32 -04:00
|
|
|
$_REQUEST['${1:variable}']
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet S
|
2013-07-25 17:17:32 -04:00
|
|
|
$_SERVER['${1:variable}']
|
2012-07-24 15:02:30 -04:00
|
|
|
snippet SS
|
2013-07-25 17:17:32 -04:00
|
|
|
$_SESSION['${1:variable}']
|
2013-04-11 21:18:57 -04:00
|
|
|
|
2012-07-28 02:16:41 -04:00
|
|
|
# the following are old ones
|
|
|
|
snippet inc
|
2013-07-25 17:17:32 -04:00
|
|
|
include '${1:file}';
|
2012-07-28 02:16:41 -04:00
|
|
|
snippet inc1
|
2013-07-25 17:17:32 -04:00
|
|
|
include_once '${1:file}';
|
2012-07-28 02:16:41 -04:00
|
|
|
snippet req
|
2013-07-25 17:17:32 -04:00
|
|
|
require '${1:file}';
|
2012-07-28 02:16:41 -04:00
|
|
|
snippet req1
|
2013-07-25 17:17:32 -04:00
|
|
|
require_once '${1:file}';
|
2011-06-20 13:40:28 -04:00
|
|
|
# Start Docblock
|
|
|
|
snippet /*
|
|
|
|
/**
|
2013-07-25 17:17:32 -04:00
|
|
|
* ${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
*/
|
|
|
|
# Class - post doc
|
|
|
|
snippet doc_cp
|
|
|
|
/**
|
|
|
|
* ${1:undocumented class}
|
|
|
|
*
|
|
|
|
* @package ${2:default}
|
2011-12-22 10:03:01 -05:00
|
|
|
* @subpackage ${3:default}
|
|
|
|
* @author ${4:`g:snips_author`}
|
2013-07-25 17:17:32 -04:00
|
|
|
*/
|
2011-06-20 13:40:28 -04:00
|
|
|
# Class Variable - post doc
|
|
|
|
snippet doc_vp
|
|
|
|
/**
|
|
|
|
* ${1:undocumented class variable}
|
|
|
|
*
|
|
|
|
* @var ${2:string}
|
2013-07-25 17:17:32 -04:00
|
|
|
*/
|
2011-06-20 13:40:28 -04:00
|
|
|
# Class Variable
|
|
|
|
snippet doc_v
|
|
|
|
/**
|
|
|
|
* ${3:undocumented class variable}
|
|
|
|
*
|
|
|
|
* @var ${4:string}
|
|
|
|
*/
|
2013-07-25 17:17:32 -04:00
|
|
|
${1:var} $${2};
|
2011-06-20 13:40:28 -04:00
|
|
|
# Class
|
|
|
|
snippet doc_c
|
|
|
|
/**
|
|
|
|
* ${3:undocumented class}
|
|
|
|
*
|
2012-02-09 10:58:46 -05:00
|
|
|
* @package ${4:default}
|
|
|
|
* @subpackage ${5:default}
|
|
|
|
* @author ${6:`g:snips_author`}
|
2011-06-20 13:40:28 -04:00
|
|
|
*/
|
|
|
|
${1:}class ${2:}
|
2012-02-09 10:58:46 -05:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
} // END $1class $2
|
|
|
|
# Constant Definition - post doc
|
|
|
|
snippet doc_dp
|
|
|
|
/**
|
|
|
|
* ${1:undocumented constant}
|
2013-07-25 17:17:32 -04:00
|
|
|
*/
|
2011-06-20 13:40:28 -04:00
|
|
|
# Constant Definition
|
|
|
|
snippet doc_d
|
|
|
|
/**
|
|
|
|
* ${3:undocumented constant}
|
|
|
|
*/
|
2013-07-25 17:17:32 -04:00
|
|
|
define(${1}, ${2});
|
2011-06-20 13:40:28 -04:00
|
|
|
# Function - post doc
|
|
|
|
snippet doc_fp
|
|
|
|
/**
|
|
|
|
* ${1:undocumented function}
|
|
|
|
*
|
|
|
|
* @return ${2:void}
|
|
|
|
* @author ${3:`g:snips_author`}
|
2013-07-25 17:17:32 -04:00
|
|
|
*/
|
2011-06-20 13:40:28 -04:00
|
|
|
# Function signature
|
|
|
|
snippet doc_s
|
|
|
|
/**
|
|
|
|
* ${4:undocumented function}
|
|
|
|
*
|
|
|
|
* @return ${5:void}
|
|
|
|
* @author ${6:`g:snips_author`}
|
|
|
|
*/
|
2013-07-25 17:17:32 -04:00
|
|
|
${1}function ${2}(${3});
|
2011-06-20 13:40:28 -04:00
|
|
|
# Function
|
|
|
|
snippet doc_f
|
|
|
|
/**
|
|
|
|
* ${4:undocumented function}
|
|
|
|
*
|
|
|
|
* @return ${5:void}
|
|
|
|
* @author ${6:`g:snips_author`}
|
|
|
|
*/
|
|
|
|
${1}function ${2}(${3})
|
2013-07-25 17:17:32 -04:00
|
|
|
{${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
|
|
|
# Header
|
|
|
|
snippet doc_h
|
|
|
|
/**
|
|
|
|
* ${1}
|
|
|
|
*
|
|
|
|
* @author ${2:`g:snips_author`}
|
|
|
|
* @version ${3:$Id$}
|
|
|
|
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
|
2013-07-25 17:17:32 -04:00
|
|
|
* @package ${0:default}
|
2011-06-20 13:40:28 -04:00
|
|
|
*/
|
2013-04-11 21:18:57 -04:00
|
|
|
|
2011-06-20 13:40:28 -04:00
|
|
|
# Interface
|
2012-07-25 00:09:06 -04:00
|
|
|
snippet interface
|
2011-06-20 13:40:28 -04:00
|
|
|
/**
|
|
|
|
* ${2:undocumented class}
|
|
|
|
*
|
|
|
|
* @package ${3:default}
|
|
|
|
* @author ${4:`g:snips_author`}
|
|
|
|
*/
|
2013-07-07 21:41:11 -04:00
|
|
|
interface ${1:`vim_snippets#Filename()`}
|
2012-07-24 15:02:30 -04:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-25 00:09:06 -04:00
|
|
|
}
|
2011-06-20 13:40:28 -04:00
|
|
|
# class ...
|
|
|
|
snippet class
|
|
|
|
/**
|
|
|
|
* ${1}
|
|
|
|
*/
|
2013-07-07 21:41:11 -04:00
|
|
|
class ${2:`vim_snippets#Filename()`}
|
2011-06-20 13:40:28 -04:00
|
|
|
{
|
|
|
|
${3}
|
2012-07-25 00:09:06 -04:00
|
|
|
/**
|
|
|
|
* ${4}
|
|
|
|
*/
|
|
|
|
${5:public} function ${6:__construct}(${7:argument})
|
2011-06-20 13:40:28 -04:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-07-28 02:16:41 -04:00
|
|
|
}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
2013-04-07 07:05:25 -04:00
|
|
|
snippet nc
|
|
|
|
namespace ${1:`substitute(substitute(expand("%:h"), '\v^\w+\/(\u)', '\1', ''), '\/', '\\\', 'g')`};
|
|
|
|
|
2013-07-07 21:41:11 -04:00
|
|
|
${2:abstract }class ${3:`vim_snippets#Filename()`}
|
2013-04-07 07:05:25 -04:00
|
|
|
{
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2013-04-07 07:05:25 -04:00
|
|
|
}
|
2011-06-20 13:40:28 -04:00
|
|
|
# define(...)
|
|
|
|
snippet def
|
2013-07-25 17:17:32 -04:00
|
|
|
define('${1}'${2});
|
2011-06-20 13:40:28 -04:00
|
|
|
# defined(...)
|
|
|
|
snippet def?
|
2013-07-25 17:17:32 -04:00
|
|
|
${1}defined('${2}')
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet wh
|
|
|
|
while (${1:/* condition */}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
|
|
|
# do ... while
|
|
|
|
snippet do
|
|
|
|
do {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
} while (${1:/* condition */});
|
|
|
|
snippet if
|
|
|
|
if (${1:/* condition */}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
2013-10-12 00:49:20 -04:00
|
|
|
snippet ifn
|
|
|
|
if (!${1:/* condition */}) {
|
|
|
|
${2}
|
|
|
|
}
|
2012-04-07 08:33:16 -04:00
|
|
|
snippet ifil
|
|
|
|
<?php if (${1:/* condition */}): ?>
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-04-07 08:33:16 -04:00
|
|
|
<?php endif; ?>
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet ife
|
|
|
|
if (${1:/* condition */}) {
|
2013-06-20 17:33:44 -04:00
|
|
|
${2}
|
2011-06-20 13:40:28 -04:00
|
|
|
} else {
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2012-04-07 08:33:16 -04:00
|
|
|
snippet ifeil
|
|
|
|
<?php if (${1:/* condition */}): ?>
|
|
|
|
${2:<!-- html... -->}
|
|
|
|
<?php else: ?>
|
|
|
|
${3:<!-- html... -->}
|
|
|
|
<?php endif; ?>
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2013-06-22 20:30:26 -04:00
|
|
|
snippet el
|
2011-06-20 13:40:28 -04:00
|
|
|
else {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
2013-06-22 20:30:26 -04:00
|
|
|
snippet eif
|
2011-06-20 13:40:28 -04:00
|
|
|
elseif (${1:/* condition */}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
|
|
|
snippet switch
|
|
|
|
switch ($${1:variable}) {
|
|
|
|
case '${2:value}':
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
2011-06-20 13:40:28 -04:00
|
|
|
break;
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
default:
|
2013-06-20 17:33:44 -04:00
|
|
|
${4}
|
2011-06-20 13:40:28 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
snippet case
|
|
|
|
case '${1:value}':
|
2013-06-20 17:33:44 -04:00
|
|
|
${2}
|
2013-07-25 17:17:32 -04:00
|
|
|
break;
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet for
|
|
|
|
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
|
|
|
snippet foreach
|
|
|
|
foreach ($${1:variable} as $${2:value}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
2012-04-07 08:33:16 -04:00
|
|
|
snippet foreachil
|
|
|
|
<?php foreach ($${1:variable} as $${2:value}): ?>
|
2013-07-25 17:17:32 -04:00
|
|
|
${0:<!-- html... -->}
|
2012-04-07 08:33:16 -04:00
|
|
|
<?php endforeach; ?>
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet foreachk
|
|
|
|
foreach ($${1:variable} as $${2:key} => $${3:value}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
}
|
2012-04-07 08:33:16 -04:00
|
|
|
snippet foreachkil
|
|
|
|
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
|
2013-07-25 17:17:32 -04:00
|
|
|
${0:<!-- html... -->}
|
2012-04-07 08:33:16 -04:00
|
|
|
<?php endforeach; ?>
|
2011-06-20 13:40:28 -04:00
|
|
|
# $... = array (...)
|
|
|
|
snippet array
|
2013-07-25 17:17:32 -04:00
|
|
|
$${1:arrayName} = array('${2}' => ${3});
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet try
|
|
|
|
try {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
} catch (${1:Exception} $e) {
|
|
|
|
}
|
|
|
|
# lambda with closure
|
|
|
|
snippet lambda
|
|
|
|
${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2011-06-20 13:40:28 -04:00
|
|
|
};
|
|
|
|
# pre_dump();
|
|
|
|
snippet pd
|
2013-07-25 17:17:32 -04:00
|
|
|
echo '<pre>'; var_dump(${0}); echo '</pre>';
|
2011-06-20 13:40:28 -04:00
|
|
|
# pre_dump(); die();
|
|
|
|
snippet pdd
|
2013-07-25 17:17:32 -04:00
|
|
|
echo '<pre>'; var_dump(${1}); echo '</pre>'; die(${0:});
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet vd
|
2013-07-25 17:17:32 -04:00
|
|
|
var_dump(${0});
|
2011-11-24 03:43:32 -05:00
|
|
|
snippet vdd
|
2013-07-25 17:17:32 -04:00
|
|
|
var_dump(${1}); die(${0:});
|
2014-08-14 02:36:45 -04:00
|
|
|
snippet pr
|
|
|
|
print_r(${0});
|
|
|
|
snippet prs
|
|
|
|
print_r(${0}, 1);
|
2013-04-13 11:57:44 -04:00
|
|
|
snippet vdf
|
2013-07-25 17:17:32 -04:00
|
|
|
error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet http_redirect
|
2013-04-11 21:18:57 -04:00
|
|
|
header ("HTTP/1.1 301 Moved Permanently");
|
|
|
|
header ("Location: ".URL);
|
2011-06-20 13:40:28 -04:00
|
|
|
exit();
|
2011-12-22 10:03:01 -05:00
|
|
|
# Getters & Setters
|
2012-12-03 11:18:40 -05:00
|
|
|
snippet gs
|
2011-12-22 10:03:01 -05:00
|
|
|
/**
|
2012-12-03 11:18:40 -05:00
|
|
|
* Gets the value of ${1:foo}
|
2011-12-22 10:03:01 -05:00
|
|
|
*
|
2012-12-03 11:18:40 -05:00
|
|
|
* @return ${2:$1}
|
2011-12-22 10:03:01 -05:00
|
|
|
*/
|
2012-12-03 11:18:40 -05:00
|
|
|
public function get${3:$2}()
|
2011-12-22 10:03:01 -05:00
|
|
|
{
|
2012-12-03 11:18:40 -05:00
|
|
|
return $this->${4:$1};
|
2011-12-22 10:03:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-12-22 10:40:48 -05:00
|
|
|
* Sets the value of $1
|
2011-12-22 10:03:01 -05:00
|
|
|
*
|
2012-12-03 11:18:40 -05:00
|
|
|
* @param $2 $$1 ${5:description}
|
2012-12-02 18:14:30 -05:00
|
|
|
*
|
2013-07-07 21:41:11 -04:00
|
|
|
* @return ${6:`vim_snippets#Filename()`}
|
2011-12-22 10:03:01 -05:00
|
|
|
*/
|
2012-12-03 11:18:40 -05:00
|
|
|
public function set$3(${7:$2 }$$1)
|
2011-12-22 10:03:01 -05:00
|
|
|
{
|
2012-12-03 11:18:40 -05:00
|
|
|
$this->$4 = $$1;
|
2012-07-24 15:02:30 -04:00
|
|
|
return $this;
|
2013-07-25 17:17:32 -04:00
|
|
|
}
|
2012-12-20 02:57:51 -05:00
|
|
|
# anotation, get, and set, useful for doctrine
|
|
|
|
snippet ags
|
|
|
|
/**
|
|
|
|
* ${1:description}
|
2013-04-11 21:18:57 -04:00
|
|
|
*
|
2013-07-25 17:17:32 -04:00
|
|
|
* @${0}
|
2012-12-20 02:57:51 -05:00
|
|
|
*/
|
|
|
|
${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;
|
|
|
|
}
|
2012-04-08 17:26:04 -04:00
|
|
|
snippet rett
|
|
|
|
return true;
|
|
|
|
snippet retf
|
|
|
|
return false;
|
2013-04-11 22:46:37 -04:00
|
|
|
snippet am
|
2013-04-11 22:50:15 -04:00
|
|
|
$${1:foo} = array_map(function($${2:v}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
${0}
|
2013-04-11 22:50:15 -04:00
|
|
|
return $$2;
|
|
|
|
}, $$1);
|
2013-04-11 22:57:14 -04:00
|
|
|
snippet aw
|
|
|
|
array_walk($${1:foo}, function(&$${2:v}, $${3:k}) {
|
2013-07-25 17:17:32 -04:00
|
|
|
$$2 = ${0};
|
2013-04-11 22:57:14 -04:00
|
|
|
});
|
2013-07-31 16:31:05 -04:00
|
|
|
|
|
|
|
# static var assign once
|
|
|
|
snippet static_var
|
|
|
|
static $${1} = null;
|
|
|
|
if (is_null($$1)){
|
|
|
|
$$1 = ${2};
|
|
|
|
}
|
2013-10-12 00:49:20 -04:00
|
|
|
|
|
|
|
snippet CSVWriter
|
|
|
|
<?php
|
|
|
|
|
|
|
|
class CSVWriter {
|
|
|
|
public function __construct($file_or_handle, $sep = "\t", $quot = '"'){
|
|
|
|
$args = func_get_args();
|
|
|
|
$mode = isset($opts['mode']) ? $opts['mode'] : 'w';
|
|
|
|
|
|
|
|
$this->f =
|
|
|
|
is_string($file_or_handle)
|
|
|
|
? fopen($file_or_handle, $mode)
|
|
|
|
: $file_or_handle;
|
|
|
|
|
|
|
|
$this->fputcsv_args = array($this->f, null, $sep, $quot);
|
|
|
|
|
|
|
|
if (!$this->f) throw new Exception('bad file descriptor');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function write($row){
|
|
|
|
$this->fputcsv_args[1] =& $row;
|
|
|
|
call_user_func_array('fputcsv', $this->fputcsv_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function close(){
|
|
|
|
if (!is_null($this->f))
|
|
|
|
fclose($this->f);
|
|
|
|
$this->f = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __destruct(){
|
|
|
|
$this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
snippet CSVIterator
|
|
|
|
|
|
|
|
// http://snipplr.com/view.php?codeview&id=1986 // modified
|
|
|
|
class CSVIterator implements Iterator
|
|
|
|
{
|
|
|
|
private $f;
|
|
|
|
private $curr;
|
|
|
|
private $rowCounter;
|
|
|
|
|
|
|
|
/* opts keys:
|
|
|
|
* row_size
|
|
|
|
* escape
|
|
|
|
* enclosure
|
|
|
|
* delimiter
|
|
|
|
*/
|
|
|
|
public function __construct( $file_or_handle, $opts = array(4096, ',') )
|
|
|
|
{
|
|
|
|
$d = function($n) use(&$opts){ return isset($opts[$n]) ? $opts[$n] : false; };
|
|
|
|
|
|
|
|
$this->combine = $d('combine');
|
|
|
|
$this->headers = $d('headers');
|
|
|
|
$this->headerCheckFunction = $d('header_check_function');
|
|
|
|
|
|
|
|
$this->f =
|
|
|
|
is_string($file_or_handle)
|
|
|
|
? fopen( $file_or_handle, 'r' )
|
|
|
|
: $file_or_handle;
|
|
|
|
if (!$this->f) throw new Exception('bad file descriptor');
|
|
|
|
$this->fgetcsv_args = array(
|
|
|
|
$this->f,
|
|
|
|
isset($opts['row_size']) ? $opts['row_size'] : 4096,
|
|
|
|
isset($opts['delimiter']) ? $opts['delimiter'] : ',',
|
|
|
|
isset($opts['enclosure']) ? $opts['enclosure'] : '"',
|
|
|
|
isset($opts['escape']) ? $opts['escape'] : '\\',
|
|
|
|
);
|
|
|
|
$this->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function readRow(){
|
|
|
|
$this->curr = call_user_func_array('fgetcsv', $this->fgetcsv_args );
|
|
|
|
$this->rowCounter++;
|
|
|
|
if ($this->rowCounter == 1){
|
|
|
|
$this->processHeader();
|
|
|
|
} elseif ($this->curr) {
|
|
|
|
$this->processRow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processHeader(){
|
|
|
|
if ($this->headers || $this->combine){
|
|
|
|
$this->header = $this->curr;
|
|
|
|
if ($this->headerCheckFunction){
|
|
|
|
$f = $this->headerCheckFunction;
|
|
|
|
$f($this->header);
|
|
|
|
}
|
|
|
|
$this->readRow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRow(){
|
|
|
|
if ($this->combine)
|
|
|
|
$this->curr = array_combine($this->header, $this->curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function start(){
|
|
|
|
$this->rowCounter = 0;
|
|
|
|
rewind( $this->f );
|
|
|
|
$this->readRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function rewind()
|
|
|
|
{
|
|
|
|
$this->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function current()
|
|
|
|
{
|
|
|
|
$curr = $this->curr;
|
|
|
|
$this->readRow();
|
|
|
|
return $curr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function key()
|
|
|
|
{
|
|
|
|
return $this->rowCounter;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function next()
|
|
|
|
{
|
|
|
|
return $this->curr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function valid(){
|
|
|
|
if( !$this->next() )
|
|
|
|
{
|
|
|
|
fclose( $this->f );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end class
|
|
|
|
|
|
|
|
snippet is
|
|
|
|
isset($1{VISUAL})
|
2013-12-08 11:11:57 -05:00
|
|
|
|
|
|
|
# phpunit
|
|
|
|
snippet ase
|
|
|
|
$this->assertEquals(${1:expected}, ${2:actual});
|
|
|
|
|
|
|
|
snippet asne
|
|
|
|
$this->assertNotEquals(${1:expected}, ${2:actual});
|
|
|
|
|
|
|
|
snippet asf
|
|
|
|
$this->assertFalse(${1:Something});
|
|
|
|
|
|
|
|
snippet ast
|
|
|
|
$this->assertTrue(${1:Something});
|
|
|
|
|
|
|
|
snippet asfex
|
|
|
|
$this->assertFileExists(${1:path/to/file});
|
|
|
|
|
|
|
|
snippet asfnex
|
|
|
|
$this->assertFileNotExists(${1:path/to/file});
|
|
|
|
|
|
|
|
snippet ascon
|
|
|
|
$this->assertContains(${1:Search Value}, ${2:Array or Iterator});
|
|
|
|
|
|
|
|
snippet ashk
|
|
|
|
$this->assertArrayHasKey(${1:key}, ${2:array});
|
|
|
|
|
|
|
|
snippet asnhk
|
|
|
|
this->assertArrayNotHasKey(${1:value}, ${2:array});
|
|
|
|
|
|
|
|
snippet ascha
|
|
|
|
$this->assertClassHasAttribute('${1:Attribute Name}', '${2:ClassName}');
|
|
|
|
|
|
|
|
snippet asi
|
|
|
|
$this->assertInstanceOf(${1:expected}, ${2:actual});
|
|
|
|
|
|
|
|
snippet tc
|
|
|
|
public function test${1:name_of_the_test}()
|
|
|
|
{
|
|
|
|
${0:code}
|
|
|
|
}
|
2015-10-03 16:34:50 -04:00
|
|
|
snippet te
|
|
|
|
throw new ${1:Exception}("${2:Error Processing Request}");
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet fpc "file_put_contents" b
|
2016-01-11 11:29:54 -05:00
|
|
|
file_put_contents(${1:file}, ${2:content}${3:, FILE_APPEND});$0
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet sr "str_replace"
|
2016-01-11 11:29:54 -05:00
|
|
|
str_replace(${1:search}, ${2:replace}, ${3:subject})$0
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet ia "in_array"
|
2016-01-11 11:29:54 -05:00
|
|
|
in_array(${1:needle}, ${2:haystack})$0
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet is "isset"
|
2016-01-11 11:29:54 -05:00
|
|
|
isset(${1:var})$0
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet isa "isset array"
|
2016-01-11 11:29:54 -05:00
|
|
|
isset($${1:array}[${2:key}])$0
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet in "is_null"
|
2016-01-11 11:29:54 -05:00
|
|
|
is_null($${1:var})$0
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet fe "file_exists"
|
2016-01-11 11:29:54 -05:00
|
|
|
file_exists(${1:file})$0
|
2016-01-11 09:28:15 -05:00
|
|
|
|
|
|
|
snippet id "is_dir"
|
2016-01-11 11:29:54 -05:00
|
|
|
is_dir(${1:path})$0
|