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: jwilliams108 <https://github.com/jwilliams108>, Eric Stern <https://github.com/firehed>
2 " Description: phpcs for PHP files
4 let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '')
6 call ale#Set('php_phpcs_options', '')
7 call ale#Set('php_phpcs_executable', 'phpcs')
8 call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0))
10 function! ale_linters#php#phpcs#GetCommand(buffer) abort
11 let l:standard = ale#Var(a:buffer, 'php_phpcs_standard')
12 let l:standard_option = !empty(l:standard)
13 \ ? '--standard=' . ale#Escape(l:standard)
16 return '%e -s --report=emacs --stdin-path=%s'
17 \ . ale#Pad(l:standard_option)
18 \ . ale#Pad(ale#Var(a:buffer, 'php_phpcs_options'))
21 function! ale_linters#php#phpcs#Handle(buffer, lines) abort
22 " Matches against lines like the following:
24 " /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
25 let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\)).*$'
28 for l:match in ale#util#GetMatches(a:lines, l:pattern)
29 let l:code = l:match[5]
30 let l:text = l:match[4] . ' (' . l:code . ')'
31 let l:type = l:match[3]
34 \ 'lnum': l:match[1] + 0,
35 \ 'col': l:match[2] + 0,
37 \ 'type': l:type is# 'error' ? 'E' : 'W',
38 \ 'sub_type': 'style',
45 call ale#linter#Define('php', {
47 \ 'executable': {b -> ale#path#FindExecutable(b, 'php_phpcs', [
52 \ 'command': function('ale_linters#php#phpcs#GetCommand'),
53 \ 'callback': 'ale_linters#php#phpcs#Handle',