From fe4c59fa2d57f05e88940173c1b92a38513611eb Mon Sep 17 00:00:00 2001 From: yuhuanbo Date: Fri, 13 Sep 2013 11:09:29 +0800 Subject: [PATCH] [php] [symfony] some bugfix and improve symfony snippet `ent` now support abstract class --- UltiSnips/php.snippets | 13 +++++++------ UltiSnips/php/symfony2.snippets | 8 ++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets index 7cc3e3c67..b7d016702 100644 --- a/UltiSnips/php.snippets +++ b/UltiSnips/php.snippets @@ -62,14 +62,15 @@ ${1:public} function __construct($2) endsnippet snippet sg "Setter and Getter" b - /** - * @var ${3:`!p snip.rv = t[2].capitalize()`} + * @var ${3:`!p snip.rv = t[2][0:1].upper() + t[2][1:]`} + * + * ${4} */ -${1:protected} $$2; +${1:protected} $${2}; -public function set`!p snip.rv = t[2].capitalize()`(`!p -if re.match(r'[A-Z].*', t[3]): +public function set`!p snip.rv = t[2][0:1].upper() + t[2][1:]`(`!p +if re.match(r'^(\\|[A-Z]).*', t[3]): snip.rv = t[3] + ' ' else: snip.rv = '' @@ -80,7 +81,7 @@ else: return $this; } -public function get`!p snip.rv = t[2].capitalize()`() +public function get`!p snip.rv = t[2][0:1].upper() + t[2][1:]`() { return $this->$2; } diff --git a/UltiSnips/php/symfony2.snippets b/UltiSnips/php/symfony2.snippets index 8fba46b9f..b5ff0ee3e 100644 --- a/UltiSnips/php/symfony2.snippets +++ b/UltiSnips/php/symfony2.snippets @@ -33,7 +33,7 @@ snippet act "symfony2 action" b public function ${1}Action(${2}) { ${6} - return $this->redirect($this->generate('home', [], false)); + return $this->redirect($this->generateUrl('home', [], false)); } endsnippet @@ -175,7 +175,11 @@ tmp = re.sub(r'\B([A-Z])', r'_\1', tmp) snip.rv = tmp.lower() `") */ -class `!p +`!p +m = re.search(r'Abstract', path) +if m: + snip.rv = 'abstract ' +`class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() ` {