From c7b3ca5957899553abc4bc1d82d296b3e00269d5 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Wed, 11 Apr 2018 16:03:25 +0200 Subject: [PATCH 1/2] [flycheck] Add options to specify level and config file --- phpstan.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/phpstan.el b/phpstan.el index c761731..1c46332 100644 --- a/phpstan.el +++ b/phpstan.el @@ -32,12 +32,34 @@ ;;;###autoload (when (featurep 'flycheck) + (flycheck-def-option-var flycheck-phpstan-config nil phpstan-checker + "Path to the phpstan configuration for current project. + +This is passed to the -l option in phpstan. It is a good idea is +to use a directory-local variable to specify this per-project." + :type 'file + :safe (lambda (x) + (stringp x) + (file-exists-p x))) + + (flycheck-def-option-var flycheck-phpstan-level "0" phpstan-checker + "Strictness level phpstan uses to check the sources. + +This is passed to the -c option in phpstan. A good idea is to +use a directory-local variable to specify this per-project." + :type 'string + :safe (lambda (x) + (and (stringp x) + (string-match-p "\\`[0-9]+\\'" x)))) + (flycheck-define-checker phpstan-checker "PHP static analyzer based on PHPStan." :command ("phpstan" "analyze" "--no-progress" "--errorFormat=raw" + (option "-l" flycheck-phpstan-level) + (option "-c" flycheck-phpstan-config) source) :working-directory (lambda (_) (php-project-get-root-dir)) :enabled (lambda () (locate-dominating-file "phpstan.neon" default-directory)) From 84c1c766877693043745c37f9806cc0639fb57b8 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Wed, 11 Apr 2018 16:03:35 +0200 Subject: [PATCH 2/2] Fix whitespace --- phpstan.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpstan.el b/phpstan.el index 1c46332..ff05ee0 100644 --- a/phpstan.el +++ b/phpstan.el @@ -54,10 +54,10 @@ use a directory-local variable to specify this per-project." (flycheck-define-checker phpstan-checker "PHP static analyzer based on PHPStan." - :command ("phpstan" - "analyze" + :command ("phpstan" + "analyze" "--no-progress" - "--errorFormat=raw" + "--errorFormat=raw" (option "-l" flycheck-phpstan-level) (option "-c" flycheck-phpstan-config) source)