dotfiles/neovim/.config/nvim/UltiSnips/php_perso.snippets
Diogo Cordeiro c6cc2d3f9d first commit
2021-02-18 17:53:07 +00:00

155 lines
2.6 KiB
Plaintext

snippet ns "namespace declaration" b
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
endsnippet
snippet class "Class declaration template with strict mode" b
<?php declare(strict_types=1);
namespace ${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
class ${1:`!p snip.rv=snip.basename`}
{
}
endsnippet
snippet classa "Class declaration template with App/ begin namespace" b
<?php
namespace App\\${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
class ${1:`!p snip.rv=snip.basename`}
{
}
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:
snip.rv = m.group().replace('/', '\\')
`};
/**
* Interface ${1:`!p snip.rv=snip.basename`}
*/
interface $1
{
public function ${3:someFunction}();$4
}
}
endsnippet
snippet pub "Public function" b
public function ${1:name}(${2:params})
{
$0${VISUAL}${3:return null;}
}
endsnippet
snippet pro "Protected function" b
protected function ${1:name}()
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pri "Private function" b
private function ${1:name}()
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pubs "Public static function" b
public static function ${1:name}()
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pros "Protected static function" b
protected static function ${1:name}()
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet pris "Private static function" b
private static function ${1:name}()
{
${VISUAL}${5:return null;}
}
$0
endsnippet
snippet fu "Function snip" b
function ${1:name}()
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet new "New class instance" b
$${1:variableName} = new ${2:${1/\w+\s*/\u$0/}}($3);
$0
endsnippet
snippet ns "namespace declaration" b
namespace ${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
endsnippet
snippet addS "doctrine add sql" b
$this->addSql("
$0
");
endsnippet
snippet classst "Symlex test class declaration" b
<?php
namespace App\\${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
use TestTools\TestCase\UnitTestCase;
class ${1:`!p snip.rv=snip.basename`} extends UnitTestCase
{
}
endsnippet
snippet @var "var phpdoc" b
/** @var $0 */
endsnippet