Merge pull request #722 from codeinabox/php-trait

Trait snippet for PHP + moved `sfa` snippet into php-symfony2
This commit is contained in:
Louis Pilfold 2016-04-30 13:52:08 +01:00
commit 2a1fa24d68
3 changed files with 42 additions and 13 deletions

View File

@ -53,6 +53,18 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
} }
endsnippet endsnippet
snippet sfa "Symfony 2 Controller action"
/**
* @Route("/${1:route_name}", name="$1")
* @Template()
*/
public function $1Action($2)
{
$3
return ${4:array();}$0
}
endsnippet
snippet act "Symfony2 action" b snippet act "Symfony2 action" b
/** /**
* @Route("${3}", name="${4}") * @Route("${3}", name="${4}")

View File

@ -314,6 +314,24 @@ interface $1
} }
endsnippet endsnippet
snippet trait "Trait declaration template" b
<?php
namespace ${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
/**
* Interface ${1:`!p snip.rv=snip.basename`}
* @author ${2:`!v g:snips_author`}
*/
trait $1
{
}
endsnippet
snippet construct "__construct()" b snippet construct "__construct()" b
/** /**
@ -333,19 +351,6 @@ snippet pc "Dumb debug helper in cli"
var_export($1);$0 var_export($1);$0
endsnippet endsnippet
# Symfony 2 based snippets
snippet sfa "Symfony 2 Controller action"
/**
* @Route("/${1:route_name}", name="$1")
* @Template()
*/
public function $1Action($2)
{
$3
return ${4:array();}$0
}
endsnippet
snippet inheritdoc "@inheritdoc docblock" snippet inheritdoc "@inheritdoc docblock"
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -218,6 +218,18 @@ snippet interface
{ {
${0} ${0}
} }
# Trait
snippet trait
/**
* ${2:undocumented class}
*
* @package ${3:default}
* @author ${4:`g:snips_author`}
*/
trait ${1:`vim_snippets#Filename()`}
{
${0}
}
# class ... # class ...
snippet class snippet class
/** /**