mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
Add php phpcbf options (#3383)
* Taken from phpcs. add add_php_phpcbf_options #3382 * Updated docs for php_phpcbf_options #3382 * Added tests #3382
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
" Description: Fixing files with phpcbf.
|
" Description: Fixing files with phpcbf.
|
||||||
|
|
||||||
call ale#Set('php_phpcbf_standard', '')
|
call ale#Set('php_phpcbf_standard', '')
|
||||||
|
call ale#Set('php_phpcbf_options', '')
|
||||||
call ale#Set('php_phpcbf_executable', 'phpcbf')
|
call ale#Set('php_phpcbf_executable', 'phpcbf')
|
||||||
call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0))
|
call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||||
|
|
||||||
@@ -20,6 +21,6 @@ function! ale#fixers#phpcbf#Fix(buffer) abort
|
|||||||
\ : ''
|
\ : ''
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ' -'
|
\ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ale#Pad(ale#Var(a:buffer, 'php_phpcbf_options')) . ' -'
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -85,6 +85,14 @@ g:ale_php_phpcbf_use_global *g:ale_php_phpcbf_use_global*
|
|||||||
See |ale-integrations-local-executables|
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_php_phpcbf_options *g:ale_php_phpcbf_options*
|
||||||
|
*b:ale_php_phpcbf_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to php-cbf
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
phpcs *ale-php-phpcs*
|
phpcs *ale-php-phpcs*
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Before:
|
|||||||
|
|
||||||
let g:ale_php_phpcbf_executable = 'phpcbf_test'
|
let g:ale_php_phpcbf_executable = 'phpcbf_test'
|
||||||
let g:ale_php_phpcbf_standard = ''
|
let g:ale_php_phpcbf_standard = ''
|
||||||
|
let g:ale_php_phpcbf_options = ''
|
||||||
let g:ale_php_phpcbf_use_global = 0
|
let g:ale_php_phpcbf_use_global = 0
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
@@ -54,6 +55,15 @@ Execute(The phpcbf callback should include the phpcbf_standard option):
|
|||||||
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml' . ' -'},
|
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml' . ' -'},
|
||||||
\ ale#fixers#phpcbf#Fix(bufnr(''))
|
\ ale#fixers#phpcbf#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(User provided options should be used):
|
||||||
|
let g:ale_php_phpcbf_options = '--my-user-provided-option my-value'
|
||||||
|
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . ale#Pad('--my-user-provided-option my-value') . ' -'},
|
||||||
|
\ ale#fixers#phpcbf#Fix(bufnr(''))
|
||||||
|
|
||||||
|
|
||||||
Before:
|
Before:
|
||||||
Save g:ale_php_phpcbf_executable
|
Save g:ale_php_phpcbf_executable
|
||||||
Save g:ale_php_phpcbf_standard
|
Save g:ale_php_phpcbf_standard
|
||||||
@@ -61,6 +71,7 @@ Before:
|
|||||||
|
|
||||||
let g:ale_php_phpcbf_executable = 'phpcbf_test'
|
let g:ale_php_phpcbf_executable = 'phpcbf_test'
|
||||||
let g:ale_php_phpcbf_standard = ''
|
let g:ale_php_phpcbf_standard = ''
|
||||||
|
let g:ale_php_phpcbf_options = ''
|
||||||
let g:ale_php_phpcbf_use_global = 0
|
let g:ale_php_phpcbf_use_global = 0
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|||||||
Reference in New Issue
Block a user