Repository navigation
Expand file tree
/
Copy pathphpstaticanalysis.vim
More file actions
57 lines (39 loc) · 1.51 KB
/
Copy pathphpstaticanalysis.vim
File metadata and controls
57 lines (39 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function! phpstaticanalysis#Psalm(...)
let paths = join(a:000, '\ ')
let cmd = 'vendor/bin/psalm --no-progress --output-format=text' . paths
let output = system(cmd)
let list = []
for line in split(output, "\n")
" Parse the filename and line number
let parts = split(line, ':')
" The reset of the string is the description
let description = join(parts[3:], ':')
" Add to the quickfix List
call add(list, { 'filename': parts[0], 'lnum': parts[1], 'col': parts[2], 'text': description })
endfor
call setqflist(list)
exe 'cwindow'
endfun
" A command to call
command -nargs=* -complete=file Psalm call phpstaticanalysis#Psalm(<f-args>)
function! phpstaticanalysis#PHPStanAnalyse(...)
let paths = join(a:000, '\ ')
let cmd = 'vendor/bin/phpstan analyse --error-format=raw --no-progress ' . paths
let output = system(cmd)
let list = []
for line in split(output, "\n")
" Parse the filename and line number
let parts = split(line, ':')
if parts[0] == '?' || parts[0] == 'Note'
continue
endif
" The reset of the string is the description
let description = join(parts[2:], ':')
" Add to the quickfix List
call add(list, { 'filename': parts[0], 'lnum': parts[1], 'text': description })
endfor
call setqflist(list)
exe 'cwindow'
endfun
" A command to call
command -nargs=* -complete=file PHPStanAnalyse call phpstaticanalysis#PHPStanAnalyse(<f-args>)