|
69 | 69 |
|
70 | 70 | ;;;###autoload |
71 | 71 | (progn |
72 | | - (defvar phpstan-executable nil) |
| 72 | + (defvar phpstan-executable nil |
| 73 | + "PHPStan excutable file. |
| 74 | +
|
| 75 | +STRING |
| 76 | + Absolute path to `phpstan' executable file. |
| 77 | +
|
| 78 | +`(root . STRING)' |
| 79 | + Relative path to `phpstan' executable file. |
| 80 | +
|
| 81 | +`(STRING . (ARGUMENTS ...))' |
| 82 | + Command name and arguments. |
| 83 | +
|
| 84 | +NIL |
| 85 | + Auto detect `phpstan' executable file.") |
73 | 86 | (make-variable-buffer-local 'phpstan-executable) |
74 | 87 | (put 'phpstan-executable 'safe-local-variable |
75 | 88 | #'(lambda (v) (if (consp v) |
76 | | - (and (eq 'root (car v)) (stringp (cdr v))) |
77 | | - (null v) (stringp v))))) |
| 89 | + (or (and (eq 'root (car v)) (stringp (cdr v))) |
| 90 | + (and (stringp (car v)) (listp (cdr v)))) |
| 91 | + (or (null v) (stringp v)))))) |
78 | 92 |
|
79 | 93 | ;; Functions: |
80 | 94 | (defun phpstan-get-config-file () |
|
98 | 112 |
|
99 | 113 | (defun phpstan-get-executable () |
100 | 114 | "Return PHPStan excutable file." |
101 | | - (let ((executable (or phpstan-executable '(root . "vendor/bin/phpstan")))) |
102 | | - (when (and (consp executable) |
103 | | - (eq 'root (car executable))) |
104 | | - (setq executable |
105 | | - (expand-file-name (cdr executable) (php-project-get-root-dir)))) |
106 | | - (if (file-exists-p executable) |
107 | | - executable |
108 | | - (or (executable-find "phpstan") |
109 | | - (error "PHPStan executable not found"))))) |
| 115 | + (cond |
| 116 | + ((and (consp phpstan-executable) |
| 117 | + (eq 'root (car phpstan-executable))) |
| 118 | + (expand-file-name (cdr phpstan-executable) (php-project-get-root-dir))) |
| 119 | + ((and phpstan-flycheck-auto-set-executable |
| 120 | + (listp phpstan-executable) |
| 121 | + (stringp (car phpstan-executable)) |
| 122 | + (listp (cdr phpstan-executable))) |
| 123 | + (cdr phpstan-executable)) |
| 124 | + ((null phpstan-executable) |
| 125 | + (let ((vendor-phpstan (expand-file-name "vendor/bin/phpstan" |
| 126 | + (php-project-get-root-dir)))) |
| 127 | + (cond |
| 128 | + ((file-exists-p vendor-phpstan) vendor-phpstan) |
| 129 | + ((executable-find "phpstan") (executable-find "phpstan")) |
| 130 | + (t (error "PHPStan executable not found"))))))) |
110 | 131 |
|
111 | 132 | ;;;###autoload |
112 | 133 | (when (featurep 'flycheck) |
|
0 commit comments