You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Go to file
Hugo Thunnissen ad4b1f25a6
ci/woodpecker/push/woodpecker Pipeline failed Details
Update copyright statements and apply some code style improvements
As suggested by Stefan Monniers patch:
 - https://mail.gnu.org/archive/html/emacs-devel/2023-08/msg00367.html
1 year ago
benchmarks Fix all byte compilation warnings and errors (for real this time (probably)) 1 year ago
test Update copyright statements and apply some code style improvements 1 year ago
.gitignore Add .cask directory to gitignore 1 year ago
.woodpecker.yml Another attempt at fixing CI 2 years ago
COPYING Add license information 3 years ago
Cask Add Cask configuration and fix some compilation warnings 1 year ago
Makefile Add Cask configuration and fix some compilation warnings 1 year ago
README.md Update README 1 year ago
compile.bash Fix oopsie in compile script 1 year ago
phpinspect-autoload.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-bmap.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-buffer.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-cache.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-changeset.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-class-struct.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-class.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-completion.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-edtrack.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-eldoc.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-fs.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-imports.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-index.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-meta.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-parse-context.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-parser.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-pipeline.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-project-struct.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-project.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-queue.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-resolve.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-resolvecontext.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-serialize.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-splayt.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-suggest.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-toc.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-token-predicates.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-type.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-util.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect-worker.el Update copyright statements and apply some code style improvements 1 year ago
phpinspect.el Update copyright statements and apply some code style improvements 1 year ago

README.md

phpinspect.el

PHPInspect is a minor mode that provides code intelligence for PHP in Emacs. At its core is a PHP parser implemented in Emacs Lisp. PHPInspect comes with backends for completion-at-point, company-mode and eldoc. A backend for xref (which provides go-to-definition functionality) is planned to be implemented at a later date. The main documentation of the mode is in the docstring of the mode itself (C-h f phpinspect-mode RET to view, or read it in the source code of phpinspect.el).

Projects and Finding Types

By default, phpinspect will recognize composer projects and read their composer.json files for autoload information which is used to find files in which the types/classes/functions you use in your code are defined. It is also possible to add an "include directory" of files that should always be read and indexed for a certain project. To do this, open a file in a project and run M-x phpinspect-project-add-include-dir. You can also edit the list of include directories via M-x customize-goup RET phpinspect RET.

Example Configuration

If you already have a completion UI setup that is able to use completion-at-point-functions as completion source, you can basically just enable phpinspect-mode and you'll be good to go. An example of a basic mode hook configuration to get the most out of phpinspect is the following:

(defun my-php-personal-hook ()
  ;; Shortcut to add use statements for classes you use.
  (define-key php-mode-map (kbd \"C-c u\") 'phpinspect-fix-imports)

  ;; Shortcuts to quickly search/open files of PHP classes.
  ;; You can make these local to php-mode, but making them global
  ;; like this makes them work in other modes/filetypes as well, which
  ;; can be handy when jumping between templates, config files and PHP code.
  (global-set-key (kbd \"C-c a\") 'phpinspect-find-class-file)
  (global-set-key (kbd \"C-c c\") 'phpinspect-find-own-class-file)

  ;; Enable phpinspect-mode
  (phpinspect-mode))

(add-hook 'php-mode-hook #'my-php-personal-hook)

Example config with company mode setup

;;;###autoload
(defun my-php-personal-hook ()
  ;; It is important to enable `company-mode' before setting
  ;; the variables below.
  (company-mode)
  (setq-local company-minimum-prefix-length 0)
  (setq-local company-tooltip-align-annotations t)
  (setq-local company-idle-delay 0.1)
  (setq-local company-backends '(phpinspect-company-backend))

  ;; Shortcut to add use statements for classes you use.
  (define-key php-mode-map (kbd "C-c u") 'phpinspect-fix-imports)

  ;; Shortcuts to quickly search/open files of PHP classes.
  (global-set-key (kbd "C-c a") 'phpinspect-find-class-file)
  (global-set-key (kbd "C-c c") 'phpinspect-find-own-class-file)

  (phpinspect-mode))

(add-hook 'php-mode-hook #'my-php-personal-hook)

Install

git clone https://git.snorba.art/hugo/phpinspect.el ~/projects/phpinspect.el
(add-to-list 'load-path "~/projects/phpinspect.el")
(require 'phpinspect)

Development

Running tests

Tests are implemented using ert. You can run them in batch mode with the following command:

emacs -L ./ -batch -l ert -l ./phpinspect.el -l ./test/phpinspect-test.el -f ert-run-tests-batch-and-exit