Skip to content

New: phpstan-hover-mode#61

Merged
zonuexe merged 9 commits intomasterfrom
feature/phpstan-hover
Feb 18, 2026
Merged

New: phpstan-hover-mode#61
zonuexe merged 9 commits intomasterfrom
feature/phpstan-hover

Conversation

@zonuexe
Copy link
Member

@zonuexe zonuexe commented Feb 18, 2026

This PR introduces an experimental hover feature for phpstan.el that displays PHPStan-inferred types directly at point, without publishing diagnostics to Flycheck/Flymake.

The implementation is centered on a new minor mode, phpstan-hover-mode, and a PHP collector script derived from SanderRonde/phpstan-vscode’s TreeFetcher.php, extended for Emacs-specific UX and additional hover targets.

8111d3889b8eb989501efc696046d894.mp4

Note

This new feature is not yet distributed due to MELPA recipe restrictions, please wait for the next update.

What’s New

  • Added experimental phpstan-hover-mode
  • Type-on-hover display without creating checker diagnostics
  • Hover support expanded for:
    • variables / assignments
    • function, method, and static method calls
    • constants and class constants
    • return, yield, yield from
    • foreach key/value variables
  • Added PHPDoc-type capture in hover data
  • phpstan-copy-dumped-type now prioritizes hover data at point
    • default: prefers PHPDoc type (when available)
    • with C-u: prefers non-PHPDoc type
    • falls back to dumped messages if hover data is unavailable

Configuration

Enable hover mode

(defun my-php-hover-setup ()
  (require 'phpstan-hover)
  (phpstan-hover-mode 1))

(add-hook 'php-mode-hook #'my-php-hover-setup)

Customization

(with-eval-after-load 'phpstan-hover
  (setopt phpstan-hover-idle-delay 0.5) ;; Show popups more quickly than the default.
  (setopt phpstan-hover-display-backend 'auto) ;; Auto-select from available popup backends.
  (setopt phpstan-hover-message-prefix "🔖 ") ;; Use a shorter emoji prefix instead of "PHPStan: ".
  (setopt phpstan-hover-show-kind-label t)) ;; Set nil to hide syntax labels in popup messages.

Copy type behavior

  • M-x phpstan-copy-dumped-type
    • prefers hover type at point (PHPDoc first)
  • C-u M-x phpstan-copy-dumped-type
    • prefers non-PHPDoc type

Acknowledgement

This feature is made possible by the work in SanderRonde/phpstan-vscode, especially TreeFetcher.php.

Huge thanks to @SanderRonde for publishing and maintaining the original implementation.

As documented in the repository:

  • phpstan-hover-tree-fetcher.php is derived from upstream TreeFetcher.php
  • It remains under the original MIT License
  • We do not claim additional copyright over upstream-derived portions

Copyright 2022 Sander Ronde (awsdfgvhbjn@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@zonuexe zonuexe merged commit 77fba8f into master Feb 18, 2026
12 of 14 checks passed
@zonuexe zonuexe deleted the feature/phpstan-hover branch February 18, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant