Skip to content

Commit 18b8e89

Browse files
committed
Add phpstan-enabled
1 parent b645857 commit 18b8e89

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

flycheck-phpstan.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
(defun flycheck-phpstan--enabled-and-set-variable ()
4848
"Return path to phpstan configure file, and set buffer execute in side effect."
49-
(let ((enabled (or phpstan-working-dir (phpstan-get-config-file))))
49+
(let ((enabled (phpstan-enabled)))
5050
(prog1 enabled
5151
(when (and phpstan-flycheck-auto-set-executable
5252
(not (and (boundp 'flycheck-phpstan-executable)

flymake-phpstan.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
(defun flymake-phpstan-turn-on ()
105105
"Enable flymake-phpstan as buffer-local Flymake backend."
106106
(interactive)
107-
(let ((enabled (or phpstan-working-dir (phpstan-get-config-file))))
107+
(let ((enabled (phpstan-enabled)))
108108
(when enabled
109109
(flymake-mode 1)
110110
(when flymake-phpstan-disable-c-mode-hooks

phpstan.el

+7
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ NIL
200200
((stringp phpstan-working-dir) phpstan-working-dir)
201201
(t (php-project-get-root-dir))))
202202

203+
(defun phpstan-enabled ()
204+
"Return non-NIL if PHPStan configured or Composer detected."
205+
(or (phpstan-get-config-file)
206+
(phpstan-get-autoload-file)
207+
(and phpstan-enable-on-no-config-file
208+
(php-project-get-root-dir))))
209+
203210
(defun phpstan-get-config-file ()
204211
"Return path to phpstan configure file or `NIL'."
205212
(if phpstan-config-file

0 commit comments

Comments
 (0)