summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-11-04 10:13:44 +0000
committerGitHub <noreply@github.com>2018-11-04 10:13:44 +0000
commit6aab3fe20929e44401f56bd7fb28cb491a742c8c (patch)
tree3628b6f4b05dedb29a247ee8c6b2b79093427501
parent93180239b9f5bf3d22d28eea2fc7b6d6a3aca09f (diff)
parentf34c089685d1437f523e9c947c06b402f12c4b95 (diff)
downloadale-6aab3fe20929e44401f56bd7fb28cb491a742c8c.zip
Merge pull request #2044 from Steap/bug/1388
PHP linter: make the path to the executable configurable
-rw-r--r--ale_linters/php/php.vim6
-rw-r--r--doc/ale-php.txt10
-rw-r--r--doc/ale.txt1
-rw-r--r--test/command_callback/test_php_command_callback.vader14
4 files changed, 29 insertions, 2 deletions
diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim
index 6470383b..5d87196c 100644
--- a/ale_linters/php/php.vim
+++ b/ale_linters/php/php.vim
@@ -1,6 +1,8 @@
" Author: Spencer Wood <https://github.com/scwood>, Adriaan Zonnenberg <amz@adriaan.xyz>
" Description: This file adds support for checking PHP with php-cli
+call ale#Set('php_php_executable', 'php')
+
function! ale_linters#php#php#Handle(buffer, lines) abort
" Matches patterns like the following:
"
@@ -30,8 +32,8 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'php',
-\ 'executable': 'php',
+\ 'executable_callback': ale#VarFunc('php_php_executable'),
\ 'output_stream': 'stdout',
-\ 'command': 'php -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --',
+\ 'command': '%e -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --',
\ 'callback': 'ale_linters#php#php#Handle',
\})
diff --git a/doc/ale-php.txt b/doc/ale-php.txt
index 2eed838e..83bc0fd5 100644
--- a/doc/ale-php.txt
+++ b/doc/ale-php.txt
@@ -204,4 +204,14 @@ g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options*
This variable can be set to pass additional options to php-cs-fixer.
===============================================================================
+php *ale-php-php*
+
+g:ale_php_php_executable *g:ale_php_php_executable*
+ *b:ale_php_php_executable*
+ Type: |String|
+ Default: `'php'`
+
+ This variable sets the executable used for php.
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 59b9f352..e4fc0e3c 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -224,6 +224,7 @@ CONTENTS *ale-contents*
phpstan.............................|ale-php-phpstan|
psalm...............................|ale-php-psalm|
php-cs-fixer........................|ale-php-php-cs-fixer|
+ php.................................|ale-php-php|
po....................................|ale-po-options|
write-good..........................|ale-po-write-good|
pod...................................|ale-pod-options|
diff --git a/test/command_callback/test_php_command_callback.vader b/test/command_callback/test_php_command_callback.vader
new file mode 100644
index 00000000..81e13f93
--- /dev/null
+++ b/test/command_callback/test_php_command_callback.vader
@@ -0,0 +1,14 @@
+Before:
+ call ale#assert#SetUpLinterTest('php', 'php')
+ let b:command_tail = ' -l -d error_reporting=E_ALL -d display_errors=1'
+ \ . ' -d log_errors=0 --'
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The executable should be configurable):
+ AssertLinter 'php', ale#Escape('php') . b:command_tail
+
+ let b:ale_php_php_executable = '/path/to/php'
+
+ AssertLinter '/path/to/php', ale#Escape('/path/to/php') . b:command_tail