|
48 | 48 | :type 'boolean |
49 | 49 | :group 'phpstan) |
50 | 50 |
|
| 51 | +;;;###autoload |
| 52 | +(progn |
| 53 | + (defvar phpstan-working-dir nil) |
| 54 | + (make-variable-buffer-local 'phpstan-working-dir) |
| 55 | + (put 'phpstan-working-dir 'safe-local-variable |
| 56 | + #'(lambda (v) (if (consp v) |
| 57 | + (and (eq 'root (car v)) (stringp (cdr v))) |
| 58 | + (null v) (stringp v))))) |
| 59 | + |
51 | 60 | ;;;###autoload |
52 | 61 | (progn |
53 | 62 | (defvar phpstan-config-file nil) |
|
108 | 117 | (or (eq 'docker v) (null v) (stringp v)))))) |
109 | 118 |
|
110 | 119 | ;; Functions: |
| 120 | +(defun phpstan-get-working-dir () |
| 121 | + "Return working directory of PHPStan. |
| 122 | +
|
| 123 | +This is different from the project root. |
| 124 | +
|
| 125 | +STRING |
| 126 | + Absolute path to `phpstan' working directory. |
| 127 | +
|
| 128 | +`(root . STRING)' |
| 129 | + Relative path to `phpstan' working directory. |
| 130 | +
|
| 131 | +NIL |
| 132 | + Use (php-project-get-root-dir) as working directory." |
| 133 | + (if (and phpstan-working-dir (consp phpstan-working-dir) (eq 'root (car phpstan-working-dir))) |
| 134 | + (expand-file-name (cdr phpstan-working-dir) (php-project-get-root-dir)) |
| 135 | + (php-project-get-root-dir))) |
| 136 | + |
111 | 137 | (defun phpstan-get-config-file () |
112 | 138 | "Return path to phpstan configure file or `NIL'." |
113 | 139 | (if phpstan-config-file |
@@ -197,7 +223,7 @@ it returns the value of `SOURCE' as it is." |
197 | 223 | (eval (phpstan-normalize-path |
198 | 224 | (flycheck-save-buffer-to-temp #'flycheck-temp-file-inplace) |
199 | 225 | (flycheck-save-buffer-to-temp #'flycheck-temp-file-system)))) |
200 | | - :working-directory (lambda (_) (php-project-get-root-dir)) |
| 226 | + :working-directory (lambda (_) (phpstan-get-working-dir)) |
201 | 227 | :enabled (lambda () (phpstan-get-config-file-and-set-flycheck-variable)) |
202 | 228 | :error-patterns |
203 | 229 | ((error line-start (1+ (not (any ":"))) ":" line ":" (message) line-end)) |
|
0 commit comments