summaryrefslogtreecommitdiff
path: root/ale_linters/php
diff options
context:
space:
mode:
authorRichard Marmorstein <twitchard@users.noreply.github.com>2018-09-27 11:48:47 -0400
committerw0rp <w0rp@users.noreply.github.com>2018-09-27 16:48:47 +0100
commit947360f714cac48cff1b3e1949b1b66b48be671e (patch)
tree75df21f7327ba0a376727f28cb2f7444d3cde391 /ale_linters/php
parent58ceb21cbc10a05f376664da31c8d7621e6d3669 (diff)
downloadale-947360f714cac48cff1b3e1949b1b66b48be671e.zip
Add psalm linter for PHP (#1893)
Diffstat (limited to 'ale_linters/php')
-rw-r--r--ale_linters/php/psalm.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/ale_linters/php/psalm.vim b/ale_linters/php/psalm.vim
new file mode 100644
index 00000000..cd20ab81
--- /dev/null
+++ b/ale_linters/php/psalm.vim
@@ -0,0 +1,28 @@
+" Author: richard marmorstein <https://github.com/twitchard>
+" Description: plugin for Psalm, static analyzer for PHP
+
+call ale#Set('php_psalm_executable', 'psalm')
+
+function! ale_linters#php#psalm#Handle(buffer, lines) abort
+ " Matches patterns like the following:
+ let l:pattern = '^.*:\(\d\+\):\(\d\+\):\(\w\+\) - \(.*\)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'lnum': l:match[1] + 0,
+ \ 'text': l:match[4],
+ \ 'type': l:match[3][:0] is# 'e' ? 'E' : 'W',
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('php', {
+\ 'name': 'psalm',
+\ 'command': '%e --diff --output-format=emacs %s',
+\ 'executable_callback': ale#VarFunc('php_psalm_executable'),
+\ 'callback': 'ale_linters#php#psalm#Handle',
+\ 'lint_file': 1,
+\})