7474 (put 'phpstan-replace-path-prefix 'safe-local-variable
7575 #' (lambda (v ) (or (null v) (stringp v)))))
7676
77+ (defconst phpstan-docker-executable " docker" )
78+
7779; ; Usually it is defined dynamically by flycheck
7880(defvar flycheck-phpstan-executable )
7981
8587STRING
8688 Absolute path to `phpstan' executable file.
8789
90+ `docker'
91+ Use Docker using phpstan/docker-image.
92+
8893`(root . STRING)'
8994 Relative path to `phpstan' executable file.
9095
98103 #' (lambda (v ) (if (consp v)
99104 (or (and (eq 'root (car v)) (stringp (cdr v)))
100105 (and (stringp (car v)) (listp (cdr v))))
101- (or (null v) (stringp v))))))
106+ (or (eq 'docker v) ( null v) (stringp v))))))
102107
103108; ; Functions:
104109(defun phpstan-get-config-file ()
@@ -119,10 +124,14 @@ NIL
119124 (when (and phpstan-flycheck-auto-set-executable
120125 (not (and (boundp 'flycheck-phpstan-executable )
121126 (symbol-value 'flycheck-phpstan-executable )))
122- (stringp (car phpstan-executable))
123- (listp (cdr phpstan-executable)))
127+ (or (eq 'docker phpstan-executable)
128+ (and (consp phpstan-executable)
129+ (stringp (car phpstan-executable))
130+ (listp (cdr phpstan-executable)))))
124131 (set (make-local-variable 'flycheck-phpstan-executable )
125- (car phpstan-executable)))))
132+ (if (eq 'docker phpstan-executable)
133+ phpstan-docker-executable
134+ (car phpstan-executable))))))
126135
127136(defun phpstan-normalize-path (source-original source )
128137 " Return normalized source file path to pass by `SOURCE-ORIGINAL' OR `SOURCE' .
@@ -133,6 +142,7 @@ it returns the value of `SOURCE' as it is."
133142 (prefix
134143 (cond
135144 ((not (null phpstan-replace-path-prefix)) phpstan-replace-path-prefix)
145+ ((eq 'docker phpstan-executable) " /app" )
136146 ((and (consp phpstan-executable)
137147 (string= " docker" (car phpstan-executable))) " /app" ))))
138148 (if prefix
@@ -153,6 +163,10 @@ it returns the value of `SOURCE' as it is."
153163(defun phpstan-get-executable ()
154164 " Return PHPStan excutable file."
155165 (cond
166+ ((eq 'docker phpstan-executable)
167+ (list " run" " --rm" " -v"
168+ (concat (expand-file-name (php-project-get-root-dir)) " :/app" )
169+ " phpstan/phpstan" ))
156170 ((and (consp phpstan-executable)
157171 (eq 'root (car phpstan-executable)))
158172 (expand-file-name (cdr phpstan-executable) (php-project-get-root-dir)))
0 commit comments