All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: diegoholiveira <https://github.com/diegoholiveira>, haginaga <https://github.com/haginaga>
2 " Description: static analyzer for PHP
4 " Define the minimum severity
5 let g:ale_php_phan_minimum_severity = get(g:, 'ale_php_phan_minimum_severity', 0)
7 let g:ale_php_phan_executable = get(g:, 'ale_php_phan_executable', 'phan')
8 let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0)
10 function! ale_linters#php#phan#GetExecutable(buffer) abort
11 let l:executable = ale#Var(a:buffer, 'php_phan_executable')
13 if ale#Var(a:buffer, 'php_phan_use_client') == 1 && l:executable is# 'phan'
14 let l:executable = 'phan_client'
20 function! ale_linters#php#phan#GetCommand(buffer) abort
21 if ale#Var(a:buffer, 'php_phan_use_client') == 1
26 \ . ale#Var(a:buffer, 'php_phan_minimum_severity')
30 let l:executable = ale_linters#php#phan#GetExecutable(a:buffer)
32 return ale#Escape(l:executable) . ' ' . l:args
35 function! ale_linters#php#phan#Handle(buffer, lines) abort
36 " Matches against lines like the following:
37 if ale#Var(a:buffer, 'php_phan_use_client') == 1
38 " Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn
39 let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$'
41 " /path/to/some-filename.php:18 ERRORTYPE message
42 let l:pattern = '^\(.*\):\(\d\+\)\s\(\w\+\)\s\(.\+\)$'
47 for l:match in ale#util#GetMatches(a:lines, l:pattern)
48 if ale#Var(a:buffer, 'php_phan_use_client') == 1
50 \ 'lnum': l:match[4] + 0,
52 \ 'filename': l:match[3],
57 \ 'lnum': l:match[2] + 0,
60 \ 'filename': l:match[1],
64 call add(l:output, l:dict)
70 call ale#linter#Define('php', {
72 \ 'executable': function('ale_linters#php#phan#GetExecutable'),
73 \ 'command': function('ale_linters#php#phan#GetCommand'),
74 \ 'callback': 'ale_linters#php#phan#Handle',