|
55 | 55 | :tag "PHP Executable"
|
56 | 56 | :type 'string)
|
57 | 57 |
|
| 58 | +(defcustom php-phpdbg-executable (list "phpdbg") |
| 59 | + "The location of the PHPDBG executable." |
| 60 | + :group 'php |
| 61 | + :tag "PHP PHPDBG Executable" |
| 62 | + :type '(repeat string)) |
| 63 | + |
| 64 | +(defcustom php-php-parse-executabe nil |
| 65 | + "The location of the php-parse executable." |
| 66 | + :group 'php |
| 67 | + :tag "PHP php-parse Executable" |
| 68 | + :type '(repeat string)) |
| 69 | + |
58 | 70 | (defcustom php-site-url "https://www.php.net/"
|
59 | 71 | "Default PHP.net site URL.
|
60 | 72 |
|
@@ -804,5 +816,29 @@ When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'.
|
804 | 816 | #'file-exists-p))))
|
805 | 817 | (find-file file))
|
806 | 818 |
|
| 819 | + |
| 820 | +(defun php-phpdbg-disassemble-file (file) |
| 821 | + "Read PHP FILE and print opcodes." |
| 822 | + (interactive (list (if (or buffer-file-name (zerop (prefix-numeric-value current-prefix-arg))) |
| 823 | + buffer-file-name |
| 824 | + (expand-file-name |
| 825 | + (read-file-name "Select PHP file: " default-directory buffer-file-name))))) |
| 826 | + (let ((args `(,@php-phpdbg-executable "-dopcache.enable_cli=1" "-p*" ,file))) |
| 827 | + (compile (mapconcat #'shell-quote-argument args " ")))) |
| 828 | + |
| 829 | +(defun php-parse-file (file) |
| 830 | + "Parse PHP FILE and print node tree." |
| 831 | + (interactive (list (if (or buffer-file-name (zerop (prefix-numeric-value current-prefix-arg))) |
| 832 | + buffer-file-name |
| 833 | + (expand-file-name |
| 834 | + (read-file-name "Select PHP file: " default-directory buffer-file-name))))) |
| 835 | + (let* ((project-dir (php-project-get-root-dir)) |
| 836 | + (executable (or php-php-parse-executabe |
| 837 | + (file-executable-p (expand-file-name "vendor/bin/php-parse" project-dir)) |
| 838 | + (executable-find "php-parse") |
| 839 | + (user-error "`php-parse' command not found"))) |
| 840 | + (args `(,@(if (listp executable) executable (list executable)) ,file))) |
| 841 | + (compile (mapconcat #'shell-quote-argument args " ")))) |
| 842 | + |
807 | 843 | (provide 'php)
|
808 | 844 | ;;; php.el ends here
|
0 commit comments