Skip to content

Commit 8d63798

Browse files
committed
Modify phpstan-enabled-and-set-flycheck-variable
1 parent 21cf970 commit 8d63798

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

phpstan.el

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,21 @@ NIL
166166
if dir
167167
return (expand-file-name name dir)))))
168168

169-
(defun phpstan-get-config-file-and-set-flycheck-variable ()
169+
(defun phpstan-enabled-and-set-flycheck-variable ()
170170
"Return path to phpstan configure file, and set buffer execute in side effect."
171-
(prog1 (phpstan-get-config-file)
172-
(when (and phpstan-flycheck-auto-set-executable
173-
(not (and (boundp 'flycheck-phpstan-executable)
174-
(symbol-value 'flycheck-phpstan-executable)))
175-
(or (eq 'docker phpstan-executable)
176-
(and (consp phpstan-executable)
177-
(stringp (car phpstan-executable))
178-
(listp (cdr phpstan-executable)))))
179-
(set (make-local-variable 'flycheck-phpstan-executable)
180-
(if (eq 'docker phpstan-executable)
181-
phpstan-docker-executable
182-
(car phpstan-executable))))))
171+
(let ((enabled (not (null (or phpstan-working-dir (phpstan-get-config-file))))))
172+
(prog1 enabled
173+
(when (and phpstan-flycheck-auto-set-executable
174+
(not (and (boundp 'flycheck-phpstan-executable)
175+
(symbol-value 'flycheck-phpstan-executable)))
176+
(or (eq 'docker phpstan-executable)
177+
(and (consp phpstan-executable)
178+
(stringp (car phpstan-executable))
179+
(listp (cdr phpstan-executable)))))
180+
(set (make-local-variable 'flycheck-phpstan-executable)
181+
(if (eq 'docker phpstan-executable)
182+
phpstan-docker-executable
183+
(car phpstan-executable)))))))
183184

184185
(defun phpstan-normalize-path (source-original &optional source)
185186
"Return normalized source file path to pass by `SOURCE-ORIGINAL' OR `SOURCE'.
@@ -244,7 +245,7 @@ it returns the value of `SOURCE' as it is."
244245
(flycheck-save-buffer-to-temp #'flycheck-temp-file-inplace)
245246
(flycheck-save-buffer-to-temp #'flycheck-temp-file-system))))
246247
:working-directory (lambda (_) (phpstan-get-working-dir))
247-
:enabled (lambda () (phpstan-get-config-file-and-set-flycheck-variable))
248+
:enabled (lambda () (phpstan-enabled-and-set-flycheck-variable))
248249
:error-patterns
249250
((error line-start (1+ (not (any ":"))) ":" line ":" (message) line-end))
250251
:modes (php-mode)

0 commit comments

Comments
 (0)