diff --git a/autoload/doge/preprocessors/php.vim b/autoload/doge/preprocessors/php.vim index 56a8370f..0a63e2a5 100644 --- a/autoload/doge/preprocessors/php.vim +++ b/autoload/doge/preprocessors/php.vim @@ -80,9 +80,7 @@ endfunction function! doge#preprocessors#php#tokens(tokens) abort if has_key(a:tokens, 'propertyName') && !empty(a:tokens['propertyName']) let l:fqn = s:get_property_type_via_constructor(a:tokens['propertyName']) - if !empty(l:fqn) - let a:tokens['type'] = l:fqn - endif + let a:tokens['type'] = l:fqn endif endfunction diff --git a/ftplugin/php.vim b/ftplugin/php.vim index 87b8765a..ed3645ed 100644 --- a/ftplugin/php.vim +++ b/ftplugin/php.vim @@ -36,14 +36,14 @@ let b:doge_patterns = [] " The {type} will be added by the doge#preprocess#php#tokens() function. " See doge#preprocessors#php#tokens(). call add(b:doge_patterns, { -\ 'match': '\m^\%(\%(public\|private\|protected\|static\|var\|const\)\s\+\)*$\([[:alnum:]_]\+\)', +\ 'match': '\m^\%(\%(public\|private\|protected\|static\|var\|const\)\s\+\)*\$\([[:alnum:]_]\+\)', \ 'match_group_names': ['propertyName'], \ 'comment': { \ 'insert': 'above', \ 'template': { \ 'phpdoc': [ \ '/**', -\ ' * @var {type}', +\ ' * @var {type|!type}', \ ' */', \ ], \ }, @@ -61,7 +61,7 @@ call add(b:doge_patterns, { \ 'match': '\m^\%(\%(public\|private\|protected\|static\|final\)\s\+\)*function\s*__construct\s*(\(.\{-}\))\s*{', \ 'match_group_names': ['parameters'], \ 'parameters': { -\ 'match': '\m\%(\([[:alnum:]_\\]\+\)\s\+\)\?&\?\($[[:alnum:]_]\+\)\%(\s*=\s*\([[:alnum:]_]\+(.\{-})\|[^,]\+\)\+\)\?', +\ 'match': '\m\%(\([[:alnum:]_\\]\+\)\s\+\)\?&\?\(\$[[:alnum:]_]\+\)\%(\s*=\s*\([[:alnum:]_]\+(.\{-})\|[^,]\+\)\+\)\?', \ 'match_group_names': ['type', 'name', 'default'], \ 'format': { \ 'phpdoc': [ @@ -104,7 +104,7 @@ call add(b:doge_patterns, { \ 'match': '\m^\%(\%(public\|private\|protected\|static\|final\)\s\+\)*function\s*\%([^(]\+\)\s*(\(.\{-}\))\s*{', \ 'match_group_names': ['parameters'], \ 'parameters': { -\ 'match': '\m\%(\([[:alnum:]_\\]\+\)\s\+\)\?&\?\($[[:alnum:]_]\+\)\%(\s*=\s*\([[:alnum:]_]\+(.\{-})\|[^,]\+\)\+\)\?', +\ 'match': '\m\%(\([[:alnum:]_\\]\+\)\s\+\)\?&\?\(\$[[:alnum:]_]\+\)\%(\s*=\s*\([[:alnum:]_]\+(.\{-})\|[^,]\+\)\+\)\?', \ 'match_group_names': ['type', 'name', 'default'], \ 'format': { \ 'phpdoc': [ diff --git a/test/filetypes/php/class-properties.vader b/test/filetypes/php/class-properties.vader index 9acc000b..bdcdaf67 100644 --- a/test/filetypes/php/class-properties.vader +++ b/test/filetypes/php/class-properties.vader @@ -20,6 +20,8 @@ Given php (class properties above and below the constructor should should resolv private $response; + private $random; + } Do (trigger doge): @@ -29,7 +31,9 @@ Do (trigger doge): \ :15\ \ - :31\ + :28\ + \ + :33\ \ Expect php (generated comments at all properties and constructor function): @@ -38,7 +42,17 @@ Expect php (generated comments at all properties and constructor function): class Test { /** - * @var string [TODO:description] + * @var string + */ + protected $migrationName; + + /** + * @var Migration + */ + protected $migration; + + /** + * [TODO:description] * * @param string $name [TODO:description] * @param Migration $migration [TODO:description] @@ -55,4 +69,9 @@ Expect php (generated comments at all properties and constructor function): */ private $response; + /** + * @var [TODO:type] + */ + private $random; + }