Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Put the following into ~.dir-locals.el~ files on the root directory of project.
(phpstan-executable . docker)
(phpstan-working-dir . (root . "path/to/dir"))
(phpstan-config-file . (root . "path/to/dir/phpstan-docker.neon"))
(phpstan-memory-limit . "1G")
(phpstan-level . 7))))
#+END_SRC

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

*** Custom variable ~phpstan-flycheck-auto-set-executable~
Set flycheck phpstan-executable automatically when non-NIL.
*** Custom variable ~phpstan-memory-limit~
Use phpstan memory limit option when non-NIL.
- STRING :: Specifies the memory limit in the same format php.ini accepts.
- ex) ~"1G"~
- ~nil~ :: Use memory limit in php.ini
13 changes: 13 additions & 0 deletions phpstan.el
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
:type 'boolean
:group 'phpstan)

(defcustom phpstan-memory-limit nil
"Set --memory-limit option."
:type '(choice (string :tag "Specifies the memory limit in the same format php.ini accepts.")
(const :tag "Not set --memory-limit option" nil))
:safe (lambda (v) (or (null v) (stringp v)))
:group 'phpstan)

;;;###autoload
(progn
(defvar phpstan-working-dir nil
Expand Down Expand Up @@ -259,6 +266,10 @@ it returns the value of `SOURCE' as it is."
((symbolp phpstan-level) (symbol-name phpstan-level))
(t phpstan-level)))

(defun phpstan-get-memory-limit ()
"Return --memory-limit value."
phpstan-memory-limit)

(defun phpstan-analyze-file (file)
"Analyze a PHPScript FILE using PHPStan."
(interactive "fChoose a PHP script: ")
Expand Down Expand Up @@ -295,11 +306,13 @@ it returns the value of `SOURCE' as it is."
(let ((executable (phpstan-get-executable))
(path (phpstan-normalize-path (phpstan-get-config-file)))
(autoload (phpstan-get-autoload-file))
(memory-limit (phpstan-get-memory-limit))
(level (phpstan-get-level)))
(append executable
(list "analyze" "--error-format=raw" "--no-progress" "--no-interaction")
(and path (list "-c" path))
(and autoload (list "-a" autoload))
(and memory-limit (list "--memory-limit" memory-limit))
(and level (list "-l" level))
(list "--"))))

Expand Down