diff --git a/flycheck-phpstan.el b/flycheck-phpstan.el index c96837e..db650ae 100644 --- a/flycheck-phpstan.el +++ b/flycheck-phpstan.el @@ -77,11 +77,6 @@ passed to `flycheck-finish-checker-process'." (string-match-p flycheck-phpstan--nofiles-message output)) (funcall next checker exit-status files output callback cwd))) -(defcustom flycheck-phpstan-fallback-to-original-analysis-if-editor-mode-unavailable t - "If non-NIL, analyze the original file when PHPStan editor mode is unavailable." - :type 'boolean - :safe #'booleanp) - (defun flycheck-phpstan--enabled-and-set-variable () "Return path to phpstan configure file, and set buffer execute in side effect." (let ((enabled (phpstan-enabled))) @@ -145,10 +140,8 @@ passed to `flycheck-finish-checker-process'." :filename file)))) (defun flycheck-phpstan-analyze-original (original) - "Return non-NIL if ORIGINAL is NIL, fallback is enabled, and buffer is modified." - (and (null original) - flycheck-phpstan-fallback-to-original-analysis-if-editor-mode-unavailable - (buffer-modified-p))) + "Return non-NIL if ORIGINAL is non-NIL and buffer is not modified." + (and original (not (buffer-modified-p)))) (flycheck-define-checker phpstan "PHP static analyzer based on PHPStan." diff --git a/flymake-phpstan.el b/flymake-phpstan.el index efa0cf1..3e24f48 100644 --- a/flymake-phpstan.el +++ b/flymake-phpstan.el @@ -52,11 +52,6 @@ :type 'boolean :group 'flymake-phpstan) -(defcustom flycheck-phpstan-fallback-to-original-analysis-if-editor-mode-unavailable t - "If non-NIL, analyze the original file when PHPStan editor mode is unavailable." - :type 'boolean - :safe #'booleanp) - (defvar-local flymake-phpstan--proc nil) (defun flymake-phpstan-make-process (root command-args report-fn source) @@ -94,10 +89,8 @@ (code (user-error "PHPStan error (exit status: %s)" code))))))) (defun flymake-phpstan-analyze-original (original) - "Return non-NIL if ORIGINAL is NIL, fallback is enabled, and buffer is modified." - (and (null original) - flymake-phpstan-fallback-to-original-analysis-if-editor-mode-unavailable - (buffer-modified-p))) + "Return non-NIL if ORIGINAL is non-NIL and buffer is not modified." + (and original (not (buffer-modified-p)))) (defun flymake-phpstan--create-temp-file () "Create temp file and return the path." diff --git a/phpstan.el b/phpstan.el index f514121..0c730cf 100644 --- a/phpstan.el +++ b/phpstan.el @@ -521,13 +521,14 @@ it returns the value of `SOURCE' as it is." (phpstan-use-xdebug-option (list "--xdebug"))) (when editor (let ((original-file (plist-get editor :original-file))) - (if (phpstan-editor-mode-available-p (car (phpstan-get-executable-and-args))) - (list "--tmp-file" (funcall (plist-get editor :temp-file)) - "--instead-of" original-file - "--" original-file) - (if (funcall (plist-get editor :analyze-original) original-file) - (list "--" original-file) - (list "--" (funcall (plist-get editor :inplace))))))) + (cond + ((funcall (plist-get editor :analyze-original) original-file) + (list "--" original-file)) + ((phpstan-editor-mode-available-p (car (phpstan-get-executable-and-args))) + (list "--tmp-file" (funcall (plist-get editor :temp-file)) + "--instead-of" original-file + "--" original-file)) + ((list "--" (funcall (plist-get editor :inplace))))))) options (and args (cons "--" args)))))