refactor the php checker
* move the phpcs code into its own function * just use g:syntastic_phpcs_conf instead of initing a local var every time the checker is invoked
This commit is contained in:
parent
b21ddb5283
commit
e0ec1a3318
@ -19,6 +19,11 @@ if !executable("php")
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
"Support passing configuration directives to phpcs
|
||||||
|
if !exists("g:syntastic_phpcs_conf")
|
||||||
|
let g:syntastic_phpcs_conf = ""
|
||||||
|
endif
|
||||||
|
|
||||||
function! SyntaxCheckers_php_Term(item)
|
function! SyntaxCheckers_php_Term(item)
|
||||||
let unexpected = matchstr(a:item['text'], "unexpected '[^']\\+'")
|
let unexpected = matchstr(a:item['text'], "unexpected '[^']\\+'")
|
||||||
if len(unexpected) < 1 | return '' | end
|
if len(unexpected) < 1 | return '' | end
|
||||||
@ -29,18 +34,7 @@ function! SyntaxCheckers_php_GetLocList()
|
|||||||
|
|
||||||
let errors = []
|
let errors = []
|
||||||
if executable("phpcs")
|
if executable("phpcs")
|
||||||
" Support passing configuration directives to phpcs through
|
let errors = s:GetPHPCSErrors()
|
||||||
" g:syntastic_phpcs_conf. This matches the method in the javascript.vim
|
|
||||||
" setup.
|
|
||||||
if !exists("g:syntastic_phpcs_conf") || empty(g:syntastic_phpcs_conf)
|
|
||||||
let phpcsconf = ""
|
|
||||||
else
|
|
||||||
let phpcsconf = g:syntastic_phpcs_conf
|
|
||||||
endif
|
|
||||||
let makeprg = "phpcs " . phpcsconf . " --report=csv ".shellescape(expand('%'))
|
|
||||||
let g:mpb_makeprg = makeprg
|
|
||||||
let errorformat = '"%f"\,%l\,%c\,%t%*[a-zA-Z]\,"%m"\,%*[a-zA-Z0-9_.-]\,%*[0-9]'
|
|
||||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let makeprg = "php -l ".shellescape(expand('%'))
|
let makeprg = "php -l ".shellescape(expand('%'))
|
||||||
@ -51,3 +45,9 @@ function! SyntaxCheckers_php_GetLocList()
|
|||||||
|
|
||||||
return errors
|
return errors
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:GetPHPCSErrors()
|
||||||
|
let makeprg = "phpcs " . g:syntastic_phpcs_conf . " --report=csv ".shellescape(expand('%'))
|
||||||
|
let errorformat = '"%f"\,%l\,%c\,%t%*[a-zA-Z]\,"%m"\,%*[a-zA-Z0-9_.-]\,%*[0-9]'
|
||||||
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||||
|
endfunction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user