129129 :safe  #'stringp  
130130 :group  'phpstan )
131131
132+ (defcustom  phpstan-enable-remote-experimental  nil 
133+  " Enable PHPStan analysis remotely by TRAMP.
134+ 
135+ When non-nil, PHPStan will be executed on a remote server for code analysis. 
136+ This feature is experimental and should be used with caution as it may 
137+ have unexpected behaviors or performance implications."  
138+  :type  'boolean 
139+  :safe  #'booleanp  
140+  :group  'phpstan )
141+ 132142(defvar-local  phpstan--use-xdebug-option nil )
133143
134144;;;### autoload 
@@ -257,11 +267,12 @@ NIL
257267
258268(defun  phpstan-enabled  ()
259269 " Return non-NIL if PHPStan configured or Composer detected." 
260-  (and  (not  (file-remote-p  default-directory)) ; ; Not support remote filesystem
261-  (or  (phpstan-get-config-file)
262-  (phpstan-get-autoload-file)
263-  (and  phpstan-enable-on-no-config-file
264-  (php-project-get-root-dir)))))
270+  (unless  (and  (not  phpstan-enable-remote-experimental)
271+  (file-remote-p  default-directory)) ; ; Not support remote filesystem by default
272+  (or  (phpstan-get-config-file)
273+  (phpstan-get-autoload-file)
274+  (and  phpstan-enable-on-no-config-file
275+  (php-project-get-root-dir)))))
265276
266277(defun  phpstan-get-config-file  ()
267278 " Return path to phpstan configure file or NIL." 
@@ -334,12 +345,19 @@ it returns the value of `SOURCE' as it is."
334345 (let  ((json-object-type 'plist ) (json-array-type 'list ))
335346 (json-read-object )))))
336347
348+ (defun  phpstan--expand-file-name  (name )
349+  " Expand file name by NAME." 
350+  (let  ((file (expand-file-name  name)))
351+  (if  (and  phpstan-enable-remote-experimental (file-remote-p  name))
352+  (tramp-file-name-localname  (tramp-dissect-file-name  name))
353+  file)))
354+ 337355;;;### autoload 
338356(defun  phpstan-analyze-this-file  ()
339357 " Analyze current buffer-file using PHPStan." 
340358 (interactive )
341-  (let  ((file (expand-file-name  (or  buffer-file-name
342-  (read-file-name  " Choose a PHP script: " 
359+  (let  ((file (phpstan-- expand-file-name (or  buffer-file-name
360+  (read-file-name  " Choose a PHP script: " 
343361 (compile  (mapconcat  #'shell-quote-argument  
344362 (phpstan-get-command-args :include-executable  t  :args  (list  file)) "  " 
345363
@@ -411,13 +429,14 @@ it returns the value of `SOURCE' as it is."
411429 (listp  (cdr  phpstan-executable)))
412430 (cdr  phpstan-executable))
413431 ((null  phpstan-executable)
414-  (let  ((vendor-phpstan (expand-file-name  " vendor/bin/phpstan" 
415-  (php-project-get-root-dir))))
432+  (let*  ((vendor-phpstan (expand-file-name  " vendor/bin/phpstan" 
433+  (php-project-get-root-dir)))
434+  (expanded-vendor-phpstan (phpstan--expand-file-name vendor-phpstan)))
416435 (cond 
417436 ((file-exists-p  vendor-phpstan)
418437 (if  (file-executable-p  vendor-phpstan)
419-  (list  vendor-phpstan)
420-  (list  php-executable vendor-phpstan)))
438+  (list  expanded- vendor-phpstan)
439+  (list  php-executable expanded- vendor-phpstan)))
421440 ((executable-find  " phpstan" list  (executable-find  " phpstan" 
422441 (t  (error  " PHPStan executable not found " )))))))
423442
@@ -434,7 +453,7 @@ it returns the value of `SOURCE' as it is."
434453 (format  " --error-format=%s  "  (or  format " raw" 
435454 " --no-progress" " --no-interaction" 
436455 (and  use-pro (list  " --pro" " --no-ansi" 
437-  (and  config (list  " -c" 
456+  (and  config (list  " -c" (phpstan--expand-file-name  config) ))
438457 (and  autoload (list  " -a" 
439458 (and  memory-limit (list  " --memory-limit" 
440459 (and  level (list  " -l" 
0 commit comments