|
37 | 37 | ;;
|
38 | 38 | ;; Return list of path to bootstrap script file.
|
39 | 39 | ;;
|
| 40 | +;; ### `php-project-get-php-executable()' |
| 41 | +;; |
| 42 | +;; Return path to PHP executable file with the project settings overriding. |
| 43 | +;; |
| 44 | +;; ### `php-project-get-phan-executable()' |
| 45 | +;; |
| 46 | +;; Return path to Phan executable file with the project settings overriding. |
| 47 | +;; Phan is a static analyzer and LSP server implementation for PHP. |
| 48 | +;; See https://github.com/phan/phan |
| 49 | +;; |
40 | 50 | ;; ## `.dir-locals.el' support
|
41 | 51 | ;;
|
42 | 52 | ;; - `php-project-coding-style'
|
|
47 | 57 | ;; - `php-project-bootstrap-scripts'
|
48 | 58 | ;; - List of path to bootstrap file of project.
|
49 | 59 | ;; (ex. (((root . "vendor/autoload.php") (root . "inc/bootstrap.php")))
|
| 60 | +;; - `php-project-php-executable' |
| 61 | +;; - Path to project specific PHP executable file. |
| 62 | +;; - If you want to use a file different from the system wide `php' command. |
| 63 | +;; - `php-project-phan-executable' |
| 64 | +;; - Path to project specific Phan executable file. |
| 65 | +;; - When not specified explicitly, it is automatically searched from |
| 66 | +;; Composer's dependency of the project and `exec-path'. |
50 | 67 | ;;
|
51 | 68 |
|
52 | 69 | ;;; Code:
|
@@ -93,6 +110,21 @@ defines constants, and sets the class loaders.")
|
93 | 110 | (make-variable-buffer-local 'php-project-bootstrap-scripts)
|
94 | 111 | (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts))
|
95 | 112 |
|
| 113 | +;;;###autoload |
| 114 | +(progn |
| 115 | + (defvar php-project-php-executable nil |
| 116 | + "Path to php executable file.") |
| 117 | + (make-variable-buffer-local 'php-project-php-executable) |
| 118 | + (put 'php-project-php-executable 'safe-local-variable |
| 119 | + #'(lambda (v) (and (stringp v) (file-executable-p v))))) |
| 120 | + |
| 121 | +;;;###autoload |
| 122 | +(progn |
| 123 | + (defvar php-project-phan-executable nil |
| 124 | + "Path to phan executable file.") |
| 125 | + (make-variable-buffer-local 'php-project-phan-executable) |
| 126 | + (put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts)) |
| 127 | + |
96 | 128 | ;;;###autoload
|
97 | 129 | (progn
|
98 | 130 | (defvar php-project-coding-style nil
|
@@ -120,6 +152,22 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
|
120 | 152 | (cl-loop for v in val collect (php-project--eval-bootstrap-scripts v)))
|
121 | 153 | (t nil)))
|
122 | 154 |
|
| 155 | +(defun php-project-get-php-executable () |
| 156 | + "Return path to PHP executable file." |
| 157 | + (cond |
| 158 | + ((and (stringp php-project-php-executable) |
| 159 | + (file-executable-p php-project-php-executable)) |
| 160 | + php-project-php-executable) |
| 161 | + ((boundp 'php-executable) php-executable) |
| 162 | + (t (executable-find "php")))) |
| 163 | + |
| 164 | +(defun php-project-get-phan-executable () |
| 165 | + "Return path to phan executable file." |
| 166 | + (or (car-safe (php-project--eval-bootstrap-scripts |
| 167 | + (list php-project-phan-executable |
| 168 | + (cons 'root "vendor/bin/phan")))) |
| 169 | + (executable-find "phan"))) |
| 170 | + |
123 | 171 | ;;;###autoload
|
124 | 172 | (defun php-project-get-bootstrap-scripts ()
|
125 | 173 | "Return list of bootstrap script."
|
|
0 commit comments