Skip to content

Commit 4c0f71e

Browse files
committed
Merge pull request #9 from jrean/custom-method-visibility
Custom method visibility
2 parents 96f0994 + b37b82f commit 4c0f71e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

plugin/php-refactoring-toolbox.vim

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ function! PhpExtractClassProperty() " {{{
201201
normal mr
202202
let l:name = expand('<cword>')
203203
call s:PhpReplaceInCurrentFunction('$' . l:name . '\>', '$this->' . l:name)
204-
call s:PhpInsertProperty(l:name, "private")
204+
let l:visibility = inputdialog("Visibility (default is private): ")
205+
if empty(l:visibility)
206+
let l:visibility = 'private'
207+
endif
208+
call s:PhpInsertProperty(l:name, l:visibility)
205209
normal `r
206210
endfunction
207211
" }}}
@@ -212,6 +216,10 @@ function! PhpExtractMethod() range " {{{
212216
return
213217
endif
214218
let l:name = inputdialog("Name of new method: ")
219+
let l:visibility = inputdialog("Visibility (default is private): ")
220+
if empty(l:visibility)
221+
let l:visibility = 'private'
222+
endif
215223
normal gv"xdmr
216224
let l:middleLine = line('.')
217225
call search(s:php_regex_func_line, 'bW')
@@ -250,14 +258,18 @@ function! PhpExtractMethod() range " {{{
250258
exec "normal! Olist(" . join(l:output, ", ") . ") = $this->" . l:name . "(" . join(l:parameters, ", ") . ");\<ESC>=3="
251259
let l:return = "return array(" . join(l:output, ", ") . ");\<CR>"
252260
endif
253-
call s:PhpInsertMethod("private", l:name, l:parametersSignature, @x . l:return)
261+
call s:PhpInsertMethod(l:visibility, l:name, l:parametersSignature, @x . l:return)
254262
normal `r
255263
endfunction
256264
" }}}
257265

258266
function! PhpCreateProperty() " {{{
259267
let l:name = inputdialog("Name of new property: ")
260-
call s:PhpInsertProperty(l:name, "private")
268+
let l:visibility = inputdialog("Visibility (default is private): ")
269+
if empty(l:visibility)
270+
let l:visibility = 'private'
271+
endif
272+
call s:PhpInsertProperty(l:name, l:visibility)
261273
endfunction
262274
" }}}
263275

0 commit comments

Comments
 (0)