PHP linter: make the path to the executable configurable

Fixes #1388
This commit is contained in:
Cyril Roelandt 2018-11-01 18:20:48 +01:00
parent 4b841b5586
commit f34c089685
4 changed files with 29 additions and 2 deletions

View File

@ -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',
\})

View File

@ -203,5 +203,15 @@ 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:

View File

@ -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|

View File

@ -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