summaryrefslogtreecommitdiff
path: root/ale_linters/php
diff options
context:
space:
mode:
authorJulien Deniau <julien.deniau@gmail.com>2019-05-02 00:14:39 +0200
committerw0rp <w0rp@users.noreply.github.com>2019-05-01 23:14:39 +0100
commitc6aae3bcfcba862028180ca6ff04242c309a767a (patch)
treeb605e024363c3d57a1002ca05468db9f1e36f59d /ale_linters/php
parent4c6f67a3d02d12a7ce2f35cc3cbe2e166ae83b72 (diff)
downloadale-c6aae3bcfcba862028180ca6ff04242c309a767a.zip
Better phpstan default configuration (#2444)
* Use phpstan config file as default whenever possible + report as error
Diffstat (limited to 'ale_linters/php')
-rw-r--r--ale_linters/php/phpstan.vim20
1 files changed, 16 insertions, 4 deletions
diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim
index ecd80a83..ca12211c 100644
--- a/ale_linters/php/phpstan.vim
+++ b/ale_linters/php/phpstan.vim
@@ -3,7 +3,7 @@
" Set to change the ruleset
let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpstan')
-let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
+let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
@@ -12,14 +12,26 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
\ ? ' -c ' . l:configuration
\ : ''
+ let l:level = ale#Var(a:buffer, 'php_phpstan_level')
+ let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon')
+
+ if empty(l:level) && empty(l:config_file_exists)
+ " if no configuration file is found, then use 4 as a default level
+ let l:level = '4'
+ endif
+
+ let l:level_option = !empty(l:level)
+ \ ? ' -l ' . l:level
+ \ : ''
+
let l:error_format = ale#semver#GTE(a:version, [0, 10, 3])
\ ? ' --error-format raw'
\ : ' --errorFormat raw'
- return '%e analyze -l'
- \ . ale#Var(a:buffer, 'php_phpstan_level')
+ return '%e analyze --no-progress'
\ . l:error_format
\ . l:configuration_option
+ \ . l:level_option
\ . ' %s'
endfunction
@@ -35,7 +47,7 @@ function! ale_linters#php#phpstan#Handle(buffer, lines) abort
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'text': l:match[3],
- \ 'type': 'W',
+ \ 'type': 'E',
\})
endfor