Skip to content

Commit b645857

Browse files
committed
Add phpstan-autoload-file variable and phpstan-get-autoload-file function
1 parent f82dc78 commit b645857

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

phpstan.el

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,24 @@ NIL
117117
(and (eq 'root (car v)) (stringp (cdr v)))
118118
(null v) (stringp v)))))
119119

120+
;;;###autoload
121+
(progn
122+
(defvar-local phpstan-autoload-file nil
123+
"Path to autoload file for PHPStan.
124+
125+
STRING
126+
Path to `phpstan' autoload file.
127+
128+
`(root . STRING)'
129+
Relative path to `phpstan' configuration file from project root directory.
130+
131+
NIL
132+
If `phpstan-enable-on-no-config-file', search \"vendor/autoload.php\" in (phpstan-get-working-dir).")
133+
(put 'phpstan-autoload-file 'safe-local-variable
134+
#'(lambda (v) (if (consp v)
135+
(and (eq 'root (car v)) (stringp (cdr v)))
136+
(null v) (stringp v)))))
137+
120138
;;;###autoload
121139
(progn
122140
(defvar-local phpstan-level nil
@@ -197,6 +215,14 @@ NIL
197215
if dir
198216
return (expand-file-name name dir))))))
199217

218+
(defun phpstan-get-autoload-file ()
219+
"Return path to autoload file or NIL."
220+
(when phpstan-autoload-file
221+
(if (and (consp phpstan-autoload-file)
222+
(eq 'root (car phpstan-autoload-file)))
223+
(expand-file-name (cdr phpstan-autoload-file) (php-project-get-root-dir))
224+
phpstan-autoload-file)))
225+
200226
(defun phpstan-normalize-path (source-original &optional source)
201227
"Return normalized source file path to pass by `SOURCE-ORIGINAL' OR `SOURCE'.
202228

0 commit comments

Comments
 (0)