Skip to content

Commit b2de7dc

Browse files
biinariCarl Willman
authored andcommitted
fix phpstan: use configured level 0 (dense-analysis#5053)
Use configured g:ale_php_phpstan_level if it is 0 (as a number rather than string). 0 (number) is considered to be empty, but '0' (string) is not.
1 parent 938b2e1 commit b2de7dc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ale_linters/php/phpstan.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
2727

2828
let l:level = ale#Var(a:buffer, 'php_phpstan_level')
2929

30+
if type(l:level) is v:t_number
31+
let l:level = string(l:level)
32+
endif
33+
3034
if empty(l:level) && empty(ale_linters#php#phpstan#FindConfigFile(a:buffer))
3135
" if no configuration file is found, then use 4 as a default level
3236
let l:level = '4'

test/linter/test_phpstan.vader

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ Execute(project with level set to 3):
5959
AssertLinter 'phpstan',
6060
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('3') . ' %s'
6161

62+
Execute(project with level set to 0):
63+
call ale#test#SetFilename('phpstan-test-files/foo/test.php')
64+
let g:ale_php_phpstan_level = 0
65+
66+
AssertLinter 'phpstan',
67+
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('0') . ' %s'
68+
6269
Execute(Custom phpstan configuration file):
6370
let g:ale_php_phpstan_configuration = 'phpstan_config'
6471

0 commit comments

Comments
 (0)