mirror of https://github.com/dense-analysis/ale
add php-cs-fixer to list of fixers
This commit is contained in:
parent
1d0690f6d7
commit
fbbb8c17d9
|
@ -130,7 +130,7 @@ formatting.
|
|||
| Objective-C++ | [clang](http://clang.llvm.org/) |
|
||||
| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server) |
|
||||
| Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) |
|
||||
| PHP | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/flow/tree/master/hack/hackfmt), [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) |
|
||||
| PHP | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/flow/tree/master/hack/hackfmt), [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer), [php-cs-fixer](http://cs.sensiolabs.org/) |
|
||||
| PO | [alex](https://github.com/wooorm/alex) !!, [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html), [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
||||
| Pod | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
||||
| Pony | [ponyc](https://github.com/ponylang/ponyc) |
|
||||
|
|
|
@ -104,6 +104,11 @@ let s:default_registry = {
|
|||
\ 'suggested_filetypes': ['php'],
|
||||
\ 'description': 'Fix PHP files with phpcbf.',
|
||||
\ },
|
||||
\ 'php_cs_fixer': {
|
||||
\ 'function': 'ale#fixers#php_cs_fixer#Fix',
|
||||
\ 'suggested_filetypes': ['php'],
|
||||
\ 'description': 'Fix PHP files with php-cs-fixer.',
|
||||
\ },
|
||||
\ 'clang-format': {
|
||||
\ 'function': 'ale#fixers#clangformat#Fix',
|
||||
\ 'suggested_filetypes': ['c', 'cpp'],
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
" Author: Julien Deniau <julien.deniau@gmail.com>
|
||||
" Description: Fixing files with php-cs-fixer.
|
||||
|
||||
call ale#Set('php_cs_fixer_executable', 'php-cs-fixer')
|
||||
call ale#Set('php_cs_fixer_use_global', 0)
|
||||
|
||||
function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [
|
||||
\ 'vendor/bin/php-cs-fixer',
|
||||
\ 'php-cs-fixer'
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#php_cs_fixer#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer)
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ' fix %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
|
||||
|
|
@ -166,5 +166,22 @@ g:ale_php_phpstan_configuration *g:ale_php_phpstan_configuration*
|
|||
This variable sets path to phpstan configuration file.
|
||||
|
||||
|
||||
===============================================================================
|
||||
php-cs-fixer *ale-php-php-cs-fixer*
|
||||
|
||||
g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable*
|
||||
*b:ale_php_cs_fixer_executable*
|
||||
Type: |String|
|
||||
Default: `'php-cs-fixer'`
|
||||
|
||||
This variable sets executable used for php-cs-fixer.
|
||||
|
||||
g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global*
|
||||
*b:ale_php_cs_fixer_use_global*
|
||||
Type: |Boolean|
|
||||
Default: `0`
|
||||
|
||||
This variable force globally installed fixer.
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
|
|
@ -159,6 +159,7 @@ CONTENTS *ale-contents*
|
|||
phpcs...............................|ale-php-phpcs|
|
||||
phpmd...............................|ale-php-phpmd|
|
||||
phpstan.............................|ale-php-phpstan|
|
||||
php-cs-fixer........................|ale-php-php-cs-fixer|
|
||||
po....................................|ale-po-options|
|
||||
write-good..........................|ale-po-write-good|
|
||||
pod...................................|ale-pod-options|
|
||||
|
@ -351,7 +352,7 @@ Notes:
|
|||
* Objective-C++: `clang`
|
||||
* OCaml: `merlin` (see |ale-ocaml-merlin|), `ols`
|
||||
* Perl: `perl -c`, `perl-critic`
|
||||
* PHP: `hack`, `hackfmt`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`
|
||||
* PHP: `hack`, `hackfmt`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer`
|
||||
* PO: `alex`!!, `msgfmt`, `proselint`, `write-good`
|
||||
* Pod: `alex`!!, `proselint`, `write-good`
|
||||
* Pony: `ponyc`
|
||||
|
|
0
test/command_callback/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer
vendored
Normal file
0
test/command_callback/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
Before:
|
||||
Save g:ale_php_cs_fixer_executable
|
||||
let g:ale_php_cs_fixer_executable = 'php-cs-fixer'
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
|
||||
Execute(project with php-cs-fixer should use local by default):
|
||||
call ale#test#SetFilename('php_paths/project-with-php-cs-fixer/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer'),
|
||||
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(use-global should override local detection):
|
||||
let g:ale_php_cs_fixer_use_global = 1
|
||||
call ale#test#SetFilename('php_paths/project-with-php-cs-fixer/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ 'php-cs-fixer',
|
||||
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(project without php-cs-fixer should use global):
|
||||
call ale#test#SetFilename('php_paths/project-without-php-cs-fixer/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ 'php-cs-fixer',
|
||||
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
|
||||
|
||||
|
||||
|
||||
|
||||
Execute(The php-cs-fixer callback should return the correct default values):
|
||||
call ale#test#SetFilename('php_paths/project-without-php-cs-fixer/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {'read_temporary_file': 1, 'command': ale#Escape('php-cs-fixer') . ' fix %t' },
|
||||
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))
|
Loading…
Reference in New Issue