Skip to content

Commit e675cf0

Browse files
authored
Merge pull request #32 from yosatak/feature/add-memory-limit-option
add feature set memory-limit option
2 parents 91e0e0e + 3dd034b commit e675cf0

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.org

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Put the following into ~.dir-locals.el~ files on the root directory of project.
4242
(phpstan-executable . docker)
4343
(phpstan-working-dir . (root . "path/to/dir"))
4444
(phpstan-config-file . (root . "path/to/dir/phpstan-docker.neon"))
45+
(phpstan-memory-limit . "1G")
4546
(phpstan-level . 7))))
4647
#+END_SRC
4748

@@ -123,3 +124,8 @@ Rule level of PHPStan analysis. Please see [[https://github.com/phpstan/phpstan
123124

124125
*** Custom variable ~phpstan-flycheck-auto-set-executable~
125126
Set flycheck phpstan-executable automatically when non-NIL.
127+
*** Custom variable ~phpstan-memory-limit~
128+
Use phpstan memory limit option when non-NIL.
129+
- STRING :: Specifies the memory limit in the same format php.ini accepts.
130+
- ex) ~"1G"~
131+
- ~nil~ :: Use memory limit in php.ini

phpstan.el

+13
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@
7777
:type 'boolean
7878
:group 'phpstan)
7979

80+
(defcustom phpstan-memory-limit nil
81+
"Set --memory-limit option."
82+
:type '(choice (string :tag "Specifies the memory limit in the same format php.ini accepts.")
83+
(const :tag "Not set --memory-limit option" nil))
84+
:safe (lambda (v) (or (null v) (stringp v)))
85+
:group 'phpstan)
86+
8087
;;;###autoload
8188
(progn
8289
(defvar phpstan-working-dir nil
@@ -259,6 +266,10 @@ it returns the value of `SOURCE' as it is."
259266
((symbolp phpstan-level) (symbol-name phpstan-level))
260267
(t phpstan-level)))
261268

269+
(defun phpstan-get-memory-limit ()
270+
"Return --memory-limit value."
271+
phpstan-memory-limit)
272+
262273
(defun phpstan-analyze-file (file)
263274
"Analyze a PHPScript FILE using PHPStan."
264275
(interactive "fChoose a PHP script: ")
@@ -295,11 +306,13 @@ it returns the value of `SOURCE' as it is."
295306
(let ((executable (phpstan-get-executable))
296307
(path (phpstan-normalize-path (phpstan-get-config-file)))
297308
(autoload (phpstan-get-autoload-file))
309+
(memory-limit (phpstan-get-memory-limit))
298310
(level (phpstan-get-level)))
299311
(append executable
300312
(list "analyze" "--error-format=raw" "--no-progress" "--no-interaction")
301313
(and path (list "-c" path))
302314
(and autoload (list "-a" autoload))
315+
(and memory-limit (list "--memory-limit" memory-limit))
303316
(and level (list "-l" level))
304317
(list "--"))))
305318

0 commit comments

Comments
 (0)