diff --git a/autoload/ale/fixers/php_cs_fixer.vim b/autoload/ale/fixers/php_cs_fixer.vim index c8f9c7b0..96c6445c 100644 --- a/autoload/ale/fixers/php_cs_fixer.vim +++ b/autoload/ale/fixers/php_cs_fixer.vim @@ -4,6 +4,7 @@ call ale#Set('php_cs_fixer_executable', 'php-cs-fixer') call ale#Set('php_cs_fixer_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('php_cs_fixer_options', '') +call ale#Set('php_cs_fixer_fix_options', '') function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort return ale#path#FindExecutable(a:buffer, 'php_cs_fixer', [ @@ -18,7 +19,8 @@ function! ale#fixers#php_cs_fixer#Fix(buffer) abort return { \ 'command': ale#Escape(l:executable) \ . ' ' . ale#Var(a:buffer, 'php_cs_fixer_options') - \ . ' fix %t', + \ . ' fix ' . ale#Var(a:buffer, 'php_cs_fixer_fix_options') + \ . ' %t', \ 'read_temporary_file': 1, \} endfunction diff --git a/test/fixers/test_php_cs_fixer.vader b/test/fixers/test_php_cs_fixer.vader index eb4d78f8..9ae98208 100644 --- a/test/fixers/test_php_cs_fixer.vader +++ b/test/fixers/test_php_cs_fixer.vader @@ -1,8 +1,10 @@ Before: Save g:ale_php_cs_fixer_executable Save g:ale_php_cs_fixer_options + Save g:ale_php_cs_fixer_fix_options let g:ale_php_cs_fixer_executable = 'php-cs-fixer' let g:ale_php_cs_fixer_options = '' + let g:ale_php_cs_fixer_fix_options = '' call ale#test#SetDirectory('/testplugin/test/fixers') @@ -45,18 +47,20 @@ Execute(The php-cs-fixer callback should return the correct default values): \ 'read_temporary_file': 1, \ 'command': ale#Escape('php-cs-fixer') \ . ' ' . g:ale_php_cs_fixer_options - \ . ' fix %t' + \ . ' fix ' . g:ale_php_cs_fixer_fix_options + \ . ' %t' \ }, \ ale#fixers#php_cs_fixer#Fix(bufnr('')) Execute(The php-cs-fixer callback should include custom php-cs-fixer options): - let g:ale_php_cs_fixer_options = '--config="$HOME/.php_cs"' + let g:ale_php_cs_fixer_options = '-nq' + let g:ale_php_cs_fixer_fix_options = '--config="$HOME/.php_cs"' call ale#test#SetFilename('../test-files/php/project-without-php-cs-fixer/test.php') AssertEqual \ { \ 'command': ale#Escape(g:ale_php_cs_fixer_executable) - \ . ' --config="$HOME/.php_cs" fix %t', + \ . ' -nq fix --config="$HOME/.php_cs" %t', \ 'read_temporary_file': 1, \ }, \ ale#fixers#php_cs_fixer#Fix(bufnr(''))