Skip to content

emacs-php/psalm.el

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

psalm.el

MELPA: psalm MELPA stable: psalm

Emacs interface to Psalm, includes checker for Flycheck.

Support version

  • Emacs 24+
  • Psalm latest/dev-master (NOT support 0.9 seriese)
  • PHP 7.1+ or Docker runtime

How to install

Install from MELPA

  1. If you have not set up MELPA, see Getting Started - MELPA.
  2. M-x package-install flycheck-psalm

How to use

For Flycheck user

(defun my-php-mode-setup ()
  "My PHP-mode hook."
  (require 'flycheck-psalm)
  (flycheck-mode t))

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

For Flymake user

(add-hook 'php-mode-hook #'flymake-psalm-turn-on)

Using Docker

Install Docker. There is currently no official Docker image we can trust, so if you want to use it, you are at your own risk.

If you always use Docker for Psalm, add the following into your .emacs file (~~/.emacs.d/init.el~)

;; Be sure to replace it with a Docker image you trust
(setq-default psalm-docker-image "your/dockerhub-image")
(setq-default psalm-executable 'docker)

Put the following into .dir-locals.el files on the root directory of project.

((nil . ((php-project-root . git)
         (psalm-executable . docker)
         (psalm-working-dir . (root . "path/to/dir"))
         (psalm-config-file . (root . "path/to/dir/psalm-docker.neon"))
         (psalm-level . 7))))

Using composer (project specific)

If your project Composer relies on psalm, you do not need to set anything.

((nil . ((php-project-root . git)
         (psalm-executable . docker)
         (psalm-working-dir . (root . "path/to/dir"))
         (psalm-config-file . (root . "path/to/dir/psalm-docker.neon"))
         (psalm-level . 7))))

Using Composer

Please install vimeo/psalm package for each user environment or project by using Composer.

If you are unfamiliar with resolving dependencies, the following shell commands are recommended.

$ composer global require vimeo/psalm

Using PHAR archive

NOTICE: We strongly recommend using the latest Psalm.

Please download psalm.phar from Releases · vimeo/psalm.

Settings

Variables for psalm are mainly controlled by directory variables (.dir-locals.el).

Frequently (root. "path/to/file") notation appears in these variables. It is relative to the top level directory of the project. In general, the directory containing one of .projectile, composer.json, .git file (or directory) is at the top level.

Please be aware that the root directory of the PHP project may NOT match either of Psalm’s %rootDir% and/or %currentWorkingDirectory%.

Typically, you would set the following .dir-locals.el.

((nil . ((php-project-root . auto)
         (psalm-executable . docker)
         (psalm-working-dir . (root . "path/to/dir/"))
         (psalm-config-file . (root . "path/to/dir/psalm-custom.neon"))
         (psalm-level . max))))

If there is a psalm.neon file in the root directory of the project, you do not need to set both psalm-working-dir and psalm-config-file.

API

Most variables defined in this package are buffer local. If you want to set it for multiple projects, use setq-default.

Local variable psalm-working-dir

Path to working directory of Psalm.

STRING
Absolute path to `psalm’ working directory.
  • ex) ~”/path/to/psalm.phar”~
(root . STRING)
Relative path to `psalm’ working directory from project root directory.
  • ex) (root . "path/to/dir")
nil
Use (php-project-get-root-dir) as working directory.

Local variable psalm-config-file

Path to project specific configuration file of Psalm.

STRING
Absolute path to psalm configuration file.
(root . STRING)
Relative path to psalm configuration file from project root directory.
NIL
Search psalm.neon(.dist) in (psalm-get-working-dir).

Local variable psalm-executable

STRING
Absolute path to `psalm’ executable file.
  • ex) ~”/path/to/psalm.phar”~
SYMBOL docker
Use Docker using psalm/docker-image.
(root . STRING)
Relative path to `psalm’ executable file from project root directory.
  • ex) (root . "script/psalm")
(STRING . (ARGUMENTS ...))
Command name and arguments.
  • ex) ("docker" "run" "--rm" "-v" "/path/to/project-dir/:/app" "your/docker-image")
nil
Auto detect psalm executable file by composer dependencies of the project or executable command in PATH environment variable.

Custom variable psalm-flycheck-auto-set-executable

Set flycheck psalm-executable automatically when non-NIL.

Custom variable (local) psalm-show-info

If non-NIL, add --show-info=true option to command line argument. This variable can be overridden locally.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published