Skip to content

Commit 77ea02d

Browse files
committed
Fix renaming with php7.4 typed properties and 8.0 union types
1 parent 44dd1f3 commit 77ea02d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugin/php-refactoring-toolbox.vim

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let s:php_regex_ns_line = '^namespace\_s\+[\\_A-Za-z0-9]*\_s*[;{]'
9090
let s:php_regex_use_line = '^use\_s\+[\\_A-Za-z0-9]\+\%(\_s\+as\_s\+[_A-Za-z0-9]\+\)\?\_s*\%(,\_s\+[\\_A-Za-z0-9]\+\%(\_s\+as\_s\+[_A-Za-z0-9]\+\)\?\_s*\)*;'
9191
let s:php_regex_class_line = '^\%(\%(final\s\+\|abstract\s\+\)\?class\>\|trait\>\)'
9292
let s:php_regex_const_line = '^\s*const\s\+[^;]\+;'
93-
let s:php_regex_member_line = '^\s*\%(\%(private\|protected\|public\|static\)\s*\)\+\$'
93+
let s:php_regex_member_line = '^\s*\%(\%(private\|protected\|public\|static\)\%(\_s\+?\?[\\|_A-Za-z0-9]\+\)\?\s*\)\+\$'
9494
let s:php_regex_func_line = '^\s*\%(\%(private\|protected\|public\|static\|abstract\)\s*\)*function\_s\+'
9595

9696
let s:php_regex_local_var = '\$\<\%(this\>\)\@![A-Za-z0-9]*'
@@ -193,14 +193,14 @@ function! PhpRenameClassVariable() " {{{
193193
let l:oldName = substitute(expand('<cword>'), '^\$*', '', '')
194194
let l:newName = inputdialog('Rename ' . l:oldName . ' to: ')
195195
if g:vim_php_refactoring_auto_validate_rename == 0
196-
if s:PhpSearchInCurrentClass('\C\%(\%(\%(public\|protected\|private\|static\)\_s\+\)\+\$\|$this->\)\@<=' . l:newName . '\>', 'n') > 0
196+
if s:PhpSearchInCurrentClass('\C\%(\%(\%(public\|protected\|private\|static\)\%(\_s\+?\?[\\|_A-Za-z0-9]\+\)\?\_s\+\)\+\$\|$this->\)\@<=' . l:newName . '\>', 'n') > 0
197197
call s:PhpEchoError(l:newName . ' seems to already exist in the current class. Rename anyway ?')
198198
if inputlist(["0. No", "1. Yes"]) == 0
199199
return
200200
endif
201201
endif
202202
endif
203-
call s:PhpReplaceInCurrentClass('\C\%(\%(\%(public\|protected\|private\|static\)\_s\+\)\+\$\|$this->\)\@<=' . l:oldName . '\>', l:newName)
203+
call s:PhpReplaceInCurrentClass('\C\%(\%(\%(public\|protected\|private\|static\)\%(\_s\+?\?[\\|_A-Za-z0-9]\+\)\?\_s\+\)\+\$\|$this->\)\@<=' . l:oldName . '\>', l:newName)
204204
endfunction
205205
" }}}
206206

0 commit comments

Comments
 (0)