Skip to content

Commit 0d2907a

Browse files
committed
Set default-directory in phpstan-analyze-project and phpstan-generate-baseline
1 parent 8650aa9 commit 0d2907a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

phpstan.el

+7-3
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,18 @@ it returns the value of `SOURCE' as it is."
344344
(defun phpstan-analyze-project ()
345345
"Analyze a PHP project using PHPStan."
346346
(interactive)
347-
(compile (mapconcat #'shell-quote-argument (phpstan-get-command-args :include-executable t) " ")))
347+
(let ((default-directory (or (php-project-get-root-dir) default-directory)))
348+
(compile (mapconcat #'shell-quote-argument (phpstan-get-command-args :include-executable t) " "))))
348349

349350
;;;###autoload
350351
(defun phpstan-generate-baseline ()
351352
"Generate PHPStan baseline file."
352353
(interactive)
353-
(compile (mapconcat #'shell-quote-argument
354-
(phpstan-get-command-args :include-executable t :options '("--generate-baseline")) " ")))
354+
(let ((default-directory (or (locate-dominating-file default-directory phpstan-baseline-file)
355+
(php-project-get-root-dir)
356+
default-directory)))
357+
(compile (mapconcat #'shell-quote-argument
358+
(phpstan-get-command-args :include-executable t :options '("--generate-baseline")) " "))))
355359

356360
;;;###autoload
357361
(defun phpstan-find-baseline-file ()

0 commit comments

Comments
 (0)