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,21 +345,26 @@ 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  (file-remote-p  name)
352+  (tramp-file-name-localname  (tramp-dissect-file-name  name))
353+  (expand-file-name  file))))
354+ 337355;;;### autoload 
338356(defun  phpstan-analyze-this-file  ()
339357 " Analyze current buffer-file using PHPStan." 
340358 (interactive )
341-  (let  ((file (phpstan-normalize-path
342-  (expand-file-name  (or  buffer-file-name
343-  (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: " 
344361 (compile  (mapconcat  #'shell-quote-argument  
345362 (phpstan-get-command-args :include-executable  t  :args  (list  file)) "  " 
346363
347364;;;### autoload 
348365(defun  phpstan-analyze-file  (file )
349366 " Analyze a PHP script FILE using PHPStan." 
350-  (interactive  (list  (phpstan-normalize-path
351-  (expand-file-name  (read-file-name  " Choose a PHP script: " 
367+  (interactive  (list  (phpstan--expand-file-name (read-file-name  " Choose a PHP script: " 
352368 (compile  (mapconcat  #'shell-quote-argument  
353369 (phpstan-get-command-args :include-executable  t  :args  (list  file)) "  " 
354370
@@ -413,13 +429,14 @@ it returns the value of `SOURCE' as it is."
413429 (listp  (cdr  phpstan-executable)))
414430 (cdr  phpstan-executable))
415431 ((null  phpstan-executable)
416-  (let  ((vendor-phpstan (expand-file-name  " vendor/bin/phpstan" 
417-  (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)))
418435 (cond 
419436 ((file-exists-p  vendor-phpstan)
420437 (if  (file-executable-p  vendor-phpstan)
421-  (list  vendor-phpstan)
422-  (list  php-executable vendor-phpstan)))
438+  (list  expanded- vendor-phpstan)
439+  (list  php-executable expanded- vendor-phpstan)))
423440 ((executable-find  " phpstan" list  (executable-find  " phpstan" 
424441 (t  (error  " PHPStan executable not found " )))))))
425442
@@ -436,7 +453,7 @@ it returns the value of `SOURCE' as it is."
436453 (format  " --error-format=%s  "  (or  format " raw" 
437454 " --no-progress" " --no-interaction" 
438455 (and  use-pro (list  " --pro" " --no-ansi" 
439-  (and  config (list  " -c" 
456+  (and  config (list  " -c" (phpstan--expand-file-name  config) ))
440457 (and  autoload (list  " -a" 
441458 (and  memory-limit (list  " --memory-limit" 
442459 (and  level (list  " -l" 
0 commit comments