From 69e6730c50f4d6db47f252be5b41fabc659b0705 Mon Sep 17 00:00:00 2001 From: Max Bucknell Date: Wed, 1 Feb 2017 09:43:47 +0000 Subject: [PATCH] Update PHP snippets --- lib/python/mbutils.py | 3 ++ vim/vim.symlink/UltiSnips/php.snippets | 41 +++++++++++++++++++------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lib/python/mbutils.py b/lib/python/mbutils.py index b4a5fa5..b60b738 100644 --- a/lib/python/mbutils.py +++ b/lib/python/mbutils.py @@ -71,6 +71,9 @@ def get_namespace(dirname): return namespace + convert_path(remainder) +def prepare_arguments(param_tags): + arguments = generate_arguments(param_tags) + def format_method(snip): '''Convert expanded snippet into method name and args.''' params = get_params_map(snip) diff --git a/vim/vim.symlink/UltiSnips/php.snippets b/vim/vim.symlink/UltiSnips/php.snippets index 8246552..4d22a52 100644 --- a/vim/vim.symlink/UltiSnips/php.snippets +++ b/vim/vim.symlink/UltiSnips/php.snippets @@ -1,5 +1,5 @@ global !p -from mbutils import get_namespace, format_method +from mbutils import get_namespace, format_method, map_type, prepare_arguments import os def full_path(filename): @@ -56,31 +56,50 @@ snippet pubf * * ${3:A slightly longer description of what you want to do. This will automatically be wrapped} * - * ${4:@tags} + * ${4:@api} + * ${5:@params} + * @return ${6:ReturnType} + * ${7:@throws ${8:ExceptionType}} */ public function ${1:methodName}( ...\$args -):returnType \{ +): `!p snip.rv = map_type(t[6])` \{ $0 \} endsnippet snippet prof -protected function ${1}( - ${2} -) \{ +/** + * ${2:Short description...} + * + * ${3:A slightly longer description of what you want to do. This will automatically be wrapped} + * + * ${4:@api} + * ${5:@tags} + * @return ${6:ReturnType} + * ${7:@throws ${8:ExceptionType}} + */ +protected function ${1:methodName}(`!p snip.rv = prepare_arguments(t[5])`): `!p snip.rv = map_type(t[6])` \{ $0 \} endsnippet snippet prif -private function ${1}( - ${2} -) \{ +/** + * ${2:Short description...} + * + * ${3:A slightly longer description of what you want to do. This will automatically be wrapped} + * + * ${4:@api} + * ${5:@tags} + * @return ${6:ReturnType} + */ +private function ${1:methodName}( + ...\$args +): `!p snip.rv = map_type(t[6])` \{ $0 -\} endsnippet snippet @param -@param ${1:Type}${2:|null} \$${3:name} ${4:Description} +@param ${1:Type}${2:|null} ${3:name} ${4:Description} endsnippet