Skip to content

Commit 8b4be09

Browse files
committed
Add :args option to phpstan-get-command-args and use nconc for optimization
1 parent e229e99 commit 8b4be09

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

phpstan.el

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ it returns the value of `SOURCE' as it is."
291291
(let ((file (expand-file-name (or buffer-file-name
292292
(read-file-name "Choose a PHP script: ")))))
293293
(compile (mapconcat #'shell-quote-argument
294-
(append (phpstan-get-command-args :include-executable t) (list file)) " "))))
294+
(phpstan-get-command-args :include-executable t :args (list file)) " "))))
295295

296296
;;;###autoload
297297
(defun phpstan-analyze-file (file)
298298
"Analyze a PHP script FILE using PHPStan."
299299
(interactive (list (expand-file-name (read-file-name "Choose a PHP script: "))))
300300
(compile (mapconcat #'shell-quote-argument
301-
(append (phpstan-get-command-args :include-executable t) (list file)) " ")))
301+
(phpstan-get-command-args :include-executable t :args (list file)) " ")))
302302

303303
;;;###autoload
304304
(defun phpstan-pro ()
@@ -346,22 +346,23 @@ it returns the value of `SOURCE' as it is."
346346
((executable-find "phpstan") (list (executable-find "phpstan")))
347347
(t (error "PHPStan executable not found")))))))
348348

349-
(cl-defun phpstan-get-command-args (&key include-executable use-pro)
349+
(cl-defun phpstan-get-command-args (&key include-executable use-pro args)
350350
"Return command line argument for PHPStan."
351351
(let ((executable-and-args (phpstan-get-executable-and-args))
352352
(path (phpstan-normalize-path (phpstan-get-config-file)))
353353
(autoload (phpstan-get-autoload-file))
354354
(memory-limit (phpstan-get-memory-limit))
355355
(level (phpstan-get-level)))
356-
(append (if include-executable (list (car executable-and-args)) nil)
357-
(cdr executable-and-args)
358-
(list "analyze" "--error-format=raw" "--no-progress" "--no-interaction")
359-
(and use-pro (list "--pro" "--no-ansi"))
360-
(and path (list "-c" path))
361-
(and autoload (list "-a" autoload))
362-
(and memory-limit (list "--memory-limit" memory-limit))
363-
(and level (list "-l" level))
364-
(list "--"))))
356+
(nconc (if include-executable (list (car executable-and-args)) nil)
357+
(cdr executable-and-args)
358+
(list "analyze" "--error-format=raw" "--no-progress" "--no-interaction")
359+
(and use-pro (list "--pro" "--no-ansi"))
360+
(and path (list "-c" path))
361+
(and autoload (list "-a" autoload))
362+
(and memory-limit (list "--memory-limit" memory-limit))
363+
(and level (list "-l" level))
364+
(list "--")
365+
args)))
365366

366367
(provide 'phpstan)
367368
;;; phpstan.el ends here

0 commit comments

Comments
 (0)