summaryrefslogtreecommitdiff
path: root/ale_linters/php
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
committerw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
commit3bebcb5d48a7150f5a318952ee309acb67fb376d (patch)
tree97edd84badca566894fd4c4f10c2a786df2fe079 /ale_linters/php
parentcdf89f8269aec31d0dfddf3a2769027d72d38155 (diff)
downloadale-3bebcb5d48a7150f5a318952ee309acb67fb376d.zip
#2132 - Replace command_chain and chain_with with ale#command#Run
Diffstat (limited to 'ale_linters/php')
-rw-r--r--ale_linters/php/phpstan.vim37
1 files changed, 9 insertions, 28 deletions
diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim
index 34d4e799..ecd80a83 100644
--- a/ale_linters/php/phpstan.vim
+++ b/ale_linters/php/phpstan.vim
@@ -6,34 +6,13 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
-function! ale_linters#php#phpstan#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'php_phpstan_executable')
-endfunction
-
-function! ale_linters#php#phpstan#VersionCheck(buffer) abort
- let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
-
- " If we have previously stored the version number in a cache, then
- " don't look it up again.
- if ale#semver#HasVersion(l:executable)
- " Returning an empty string skips this command.
- return ''
- endif
-
- let l:executable = ale#Escape(l:executable)
-
- return l:executable . ' --version'
-endfunction
-
-function! ale_linters#php#phpstan#GetCommand(buffer, version_output) abort
+function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration')
let l:configuration_option = !empty(l:configuration)
\ ? ' -c ' . l:configuration
\ : ''
- let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
- let l:version = ale#semver#GetVersion(l:executable, a:version_output)
- let l:error_format = ale#semver#GTE(l:version, [0, 10, 3])
+ let l:error_format = ale#semver#GTE(a:version, [0, 10, 3])
\ ? ' --error-format raw'
\ : ' --errorFormat raw'
@@ -65,10 +44,12 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpstan',
-\ 'executable': function('ale_linters#php#phpstan#GetExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#php#phpstan#VersionCheck'},
-\ {'callback': 'ale_linters#php#phpstan#GetCommand'},
-\ ],
+\ 'executable': {b -> ale#Var(b, 'php_phpstan_executable')},
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale#Var(buffer, 'php_phpstan_executable'),
+\ '%e --version',
+\ function('ale_linters#php#phpstan#GetCommand'),
+\ )},
\ 'callback': 'ale_linters#php#phpstan#Handle',
\})