]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/php/php.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '294584081929424aec883f90c7d6515b3743358d' as '.vim/bundle/vim-lsp-ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / php / php.vim
1 " Author: Spencer Wood <https://github.com/scwood>, Adriaan Zonnenberg <amz@adriaan.xyz>
2 " Description: This file adds support for checking PHP with php-cli
3
4 call ale#Set('php_php_executable', 'php')
5
6 function! ale_linters#php#php#Handle(buffer, lines) abort
7     " Matches patterns like the following:
8     "
9     " PHP 7.1<= - Parse error:  syntax error, unexpected ';', expecting ']' in - on line 15
10     " PHP 7.2>= - Parse error:  syntax error, unexpected ';', expecting ']' in Standard input code on line 15
11     let l:pattern = '\v^%(Fatal|Parse) error:\s+(.+unexpected ''(.+)%(expecting.+)@<!''.*|.+) in %(-|Standard input code) on line (\d+)'
12     let l:output = []
13
14     for l:match in ale#util#GetMatches(a:lines, l:pattern)
15         let l:col = empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1
16
17         let l:obj = {
18         \   'lnum': l:match[3] + 0,
19         \   'col': l:col,
20         \   'text': l:match[1],
21         \}
22
23         if l:col != 0
24             let l:obj.end_col = l:col + strlen(l:match[2]) - 1
25         endif
26
27         call add(l:output, l:obj)
28     endfor
29
30     return l:output
31 endfunction
32
33 call ale#linter#Define('php', {
34 \   'name': 'php',
35 \   'executable': {b -> ale#Var(b, 'php_php_executable')},
36 \   'output_stream': 'stdout',
37 \   'command': '%e -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --',
38 \   'callback': 'ale_linters#php#php#Handle',
39 \})