Skip to content

Commit

Permalink
fix(php): Add TODO context for class properties including missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Jul 30, 2019
1 parent 3c0bf73 commit 9b5bbae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
4 changes: 1 addition & 3 deletions autoload/doge/preprocessors/php.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions ftplugin/php.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
\ ' */',
\ ],
\ },
Expand All @@ -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': [
Expand Down Expand Up @@ -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': [
Expand Down
23 changes: 21 additions & 2 deletions test/filetypes/php/class-properties.vader
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Given php (class properties above and below the constructor should should resolv

private $response;

private $random;

}

Do (trigger doge):
Expand All @@ -29,7 +31,9 @@ Do (trigger doge):
\<C-d>
:15\<CR>
\<C-d>
:31\<CR>
:28\<CR>
\<C-d>
:33\<CR>
\<C-d>

Expect php (generated comments at all properties and constructor function):
Expand All @@ -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]
Expand All @@ -55,4 +69,9 @@ Expect php (generated comments at all properties and constructor function):
*/
private $response;

/**
* @var [TODO:type]
*/
private $random;

}

0 comments on commit 9b5bbae

Please sign in to comment.