summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArie Oldman <arie.oldman@vhs7.tv>2021-11-12 16:18:49 +1100
committerGitHub <noreply@github.com>2021-11-12 14:18:49 +0900
commitff26ed72312838acbc801cc5e410faa5bab181e1 (patch)
treee39fa8e2b1cbc5ae77eaee2fe6d0d5821b035fc2
parenta9d7f45924b97a5244fb626dd9ae0bf934ca1ee6 (diff)
downloadale-ff26ed72312838acbc801cc5e410faa5bab181e1.zip
Adds --memory-limit support for phpstan (#3973)
* Adds --memmory-limit option for PHPStan linter * Updates docs for phpstan --memory-limit option. * Adds Arizard to authors * Adds test for phpstan memory limit parameter * Fixes order of parameters in test * Changes dash to underscore
-rw-r--r--ale_linters/php/phpstan.vim9
-rw-r--r--doc/ale-php.txt9
-rw-r--r--test/linter/test_phpstan.vader6
3 files changed, 23 insertions, 1 deletions
diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim
index 58d4dce2..4dce5d5f 100644
--- a/ale_linters/php/phpstan.vim
+++ b/ale_linters/php/phpstan.vim
@@ -1,4 +1,4 @@
-" Author: medains <https://github.com/medains>, ardis <https://github.com/ardisdreelath>
+" Author: medains <https://github.com/medains>, ardis <https://github.com/ardisdreelath>, Arizard <https://github.com/Arizard>
" Description: phpstan for PHP files
" Set to change the ruleset
@@ -6,6 +6,7 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
let g:ale_php_phpstan_autoload = get(g:, 'ale_php_phpstan_autoload', '')
+let g:ale_php_phpstan_memory_limit = get(g:, 'ale_php_phpstan_memory_limit', '')
call ale#Set('php_phpstan_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
@@ -19,6 +20,11 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
\ ? ' -a ' . ale#Escape(l:autoload)
\ : ''
+ let l:memory_limit = ale#Var(a:buffer, 'php_phpstan_memory_limit')
+ let l:memory_limit_option = !empty(l:memory_limit)
+ \ ? ' --memory-limit ' . ale#Escape(l:memory_limit)
+ \ : ''
+
let l:level = ale#Var(a:buffer, 'php_phpstan_level')
let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon')
let l:dist_config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon.dist')
@@ -41,6 +47,7 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
\ . l:configuration_option
\ . l:autoload_option
\ . l:level_option
+ \ . l:memory_limit_option
\ . ' %s'
endfunction
diff --git a/doc/ale-php.txt b/doc/ale-php.txt
index 4ee016fb..1c9822dc 100644
--- a/doc/ale-php.txt
+++ b/doc/ale-php.txt
@@ -187,6 +187,15 @@ g:ale_php_phpstan_autoload *g:ale_php_phpstan_autoload*
This variable sets path to phpstan autoload file.
+g:ale_php_phpstan_memory_limit *g:ale_php_phpstan_memory-limit*
+ *b:ale_php_phpstan_memory-limit*
+ Type: |String|
+ Default: `''`
+
+ This variable sets the memory limit for phpstan analysis. This is a string
+ in the same format as `php.ini` accepts, e.g. `128M`, `1G`.
+
+
===============================================================================
psalm *ale-php-psalm*
diff --git a/test/linter/test_phpstan.vader b/test/linter/test_phpstan.vader
index b5b3d3b7..dbeb1bd1 100644
--- a/test/linter/test_phpstan.vader
+++ b/test/linter/test_phpstan.vader
@@ -113,3 +113,9 @@ Execute(Autoload parameter is added to the command):
AssertLinter 'phpstan',
\ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -a ' . ale#Escape('autoload.php') . ' -l ' . ale#Escape('4') . ' %s'
+
+Execute(Memory limit parameter is added to the command):
+ let g:ale_php_phpstan_memory_limit = '500M'
+
+ AssertLinter 'phpstan',
+ \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' --memory-limit ' . ale#Escape('500M') . ' %s'