Escape phpstan arguments, and update documentation

This commit is contained in:
w0rp 2019-05-07 19:38:32 +01:00
parent c10da0e390
commit 5f64f8dc57
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
3 changed files with 13 additions and 11 deletions

View File

@ -9,7 +9,7 @@ let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '
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
\ ? ' -c ' . ale#Escape(l:configuration)
\ : ''
let l:level = ale#Var(a:buffer, 'php_phpstan_level')
@ -21,7 +21,7 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
endif
let l:level_option = !empty(l:level)
\ ? ' -l ' . l:level
\ ? ' -l ' . ale#Escape(l:level)
\ : ''
let l:error_format = ale#semver#GTE(a:version, [0, 10, 3])

View File

@ -154,11 +154,13 @@ g:ale_php_phpstan_executable *g:ale_php_phpstan_executable*
g:ale_php_phpstan_level *g:ale_php_phpstan_level*
*b:ale_php_phpstan_level*
Type: |Number|
Default: `4`
Type: |String|
Default: `''`
This variable controls the rule levels. 0 is the loosest and 4 is the
strictest.
strictest. If this option isn't set, the rule level will be controlled by
the configuration file. If no configuration file can be detected, `'4'` will
be used instead.
g:ale_php_phpstan_configuration *g:ale_php_phpstan_configuration*

View File

@ -12,27 +12,27 @@ Execute(Custom executables should be used for the executable and command):
let g:ale_php_phpstan_executable = 'phpstan_test'
AssertLinter 'phpstan_test',
\ ale#Escape('phpstan_test') . ' analyze --no-progress --errorFormat raw -l 4 %s'
\ ale#Escape('phpstan_test') . ' analyze --no-progress --errorFormat raw -l ' . ale#Escape('4') . ' %s'
Execute(project with level set to 3):
call ale#test#SetFilename('phpstan-test-files/foo/test.php')
let g:ale_php_phpstan_level = 3
AssertLinter 'phpstan',
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -l 3 %s'
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -l ' . ale#Escape('3') . ' %s'
Execute(Custom phpstan configuration file):
let g:ale_php_phpstan_configuration = 'phpstan_config'
AssertLinter 'phpstan',
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -c phpstan_config -l 4 %s'
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -c ' . ale#Escape('phpstan_config') . ' -l ' . ale#Escape('4') . ' %s'
Execute(Choose the right format for error format param):
GivenCommandOutput ['0.10.3']
AssertLinter 'phpstan', [
\ ale#Escape('phpstan') . ' --version',
\ ale#Escape('phpstan') . ' analyze --no-progress --error-format raw -l 4 %s'
\ ale#Escape('phpstan') . ' analyze --no-progress --error-format raw -l ' . ale#Escape('4') . ' %s'
\ ]
Execute(Configuration file exists in current directory):
@ -52,7 +52,7 @@ Execute(Configuration file exists in current directory, but force phpstan level)
AssertLinter 'phpstan', [
\ ale#Escape('phpstan') . ' --version',
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -l 7 %s'
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -l ' . ale#Escape('7') . ' %s'
\ ]
Execute(Configuration file exists in current directory, but force phpstan configuration):
@ -62,5 +62,5 @@ Execute(Configuration file exists in current directory, but force phpstan config
AssertLinter 'phpstan', [
\ ale#Escape('phpstan') . ' --version',
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -c phpstan.custom.neon %s'
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -c ' . ale#Escape('phpstan.custom.neon') . ' %s'
\ ]