Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this

## Unreleased

### Added

* Add `php-topsy-beginning-of-defun-with-class` to display classname with function signature. ([#766])

### Removed

* Removed Phan-specific features from `php-project` ([#754])

[#754]: https://github.com/emacs-php/php-mode/pull/754
[#766]: https://github.com/emacs-php/php-mode/pull/766

## [1.25.0] - 2023-07-24

Expand Down
31 changes: 31 additions & 0 deletions lisp/php.el
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ a completion list."
:type 'integer
:link '(url-link :tag "Built-in web server"
"https://www.php.net/manual/features.commandline.webserver.php"))

(defcustom php-topsy-separator " > "
"Separator string for `php-topsy-beginning-of-defun-with-class'."
:group 'php
:tag "PHP Topsy Separator"
:type 'string)

;;; PHP Keywords
(defconst php-magical-constants
Expand Down Expand Up @@ -655,6 +661,31 @@ Look at the `php-executable' variable instead of the constant \"php\" command."
(if (string= class "") "" (concat "\\" class "::"))
(if (string= namedfunc "") "" (concat namedfunc "()"))))))

(defun php-topsy-beginning-of-defun-with-class ()
"Return function signature and class name string for header line in topsy.

You can add the function to topsy with the code below:
\(add-to-list 'topsy-mode-functions '(php-mode . php-topsy-beginning-of-defun-with-class))"
(save-excursion
(goto-char (window-start))
(mapconcat
#'identity
(append
(save-match-data
(save-excursion
(when (re-search-backward php--re-classlike-pattern nil t)
(font-lock-ensure (point) (line-end-position))
(list (string-trim (buffer-substring (point) (line-end-position)))))))
(progn
(beginning-of-defun)
(font-lock-ensure (point) (line-end-position))
(list (string-trim
(replace-regexp-in-string
(eval-when-compile (rx bos "<?php"))
""
(buffer-substring (point) (line-end-position)))))))
php-topsy-separator)))

;;;###autoload
(defun php-run-builtin-web-server (router-or-dir hostname port &optional document-root)
"Run PHP Built-in web server.
Expand Down