summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDale Jung <dale@dalejung.com>2020-11-21 15:19:02 -0500
committerGitHub <noreply@github.com>2020-11-21 20:19:02 +0000
commit2873be2d6a5e383edd1fead396a53a8a38eebd76 (patch)
treed3607b2c6db4cb98c8c862ad07244ed136106c26
parentd1246ea8d5d22e17fc8b6c6ace836d3eec89fa6d (diff)
downloadale-2873be2d6a5e383edd1fead396a53a8a38eebd76.zip
Add php phpcbf options (#3383)
* Taken from phpcs. add add_php_phpcbf_options #3382 * Updated docs for php_phpcbf_options #3382 * Added tests #3382
-rw-r--r--autoload/ale/fixers/phpcbf.vim3
-rw-r--r--doc/ale-php.txt8
-rw-r--r--test/fixers/test_phpcbf_fixer_callback.vader11
3 files changed, 21 insertions, 1 deletions
diff --git a/autoload/ale/fixers/phpcbf.vim b/autoload/ale/fixers/phpcbf.vim
index f14b8406..0a61c657 100644
--- a/autoload/ale/fixers/phpcbf.vim
+++ b/autoload/ale/fixers/phpcbf.vim
@@ -2,6 +2,7 @@
" Description: Fixing files with phpcbf.
call ale#Set('php_phpcbf_standard', '')
+call ale#Set('php_phpcbf_options', '')
call ale#Set('php_phpcbf_executable', 'phpcbf')
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 {
- \ '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
diff --git a/doc/ale-php.txt b/doc/ale-php.txt
index 79d9a033..6da21046 100644
--- a/doc/ale-php.txt
+++ b/doc/ale-php.txt
@@ -85,6 +85,14 @@ g:ale_php_phpcbf_use_global *g:ale_php_phpcbf_use_global*
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*
diff --git a/test/fixers/test_phpcbf_fixer_callback.vader b/test/fixers/test_phpcbf_fixer_callback.vader
index 1663c89c..f7bcc2d8 100644
--- a/test/fixers/test_phpcbf_fixer_callback.vader
+++ b/test/fixers/test_phpcbf_fixer_callback.vader
@@ -5,6 +5,7 @@ Before:
let g:ale_php_phpcbf_executable = 'phpcbf_test'
let g:ale_php_phpcbf_standard = ''
+ let g:ale_php_phpcbf_options = ''
let g:ale_php_phpcbf_use_global = 0
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' . ' -'},
\ 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:
Save g:ale_php_phpcbf_executable
Save g:ale_php_phpcbf_standard
@@ -61,6 +71,7 @@ Before:
let g:ale_php_phpcbf_executable = 'phpcbf_test'
let g:ale_php_phpcbf_standard = ''
+ let g:ale_php_phpcbf_options = ''
let g:ale_php_phpcbf_use_global = 0
call ale#test#SetDirectory('/testplugin/test/fixers')