|
1 | | -* phpstan.el |
| 1 | +* psalm.el |
2 | 2 | #+BEGIN_HTML |
3 | | -<a href="http://melpa.org/#/phpstan"><img alt="MELPA: phpstan" src="http://melpa.org/packages/phpstan-badge.svg"></a> |
4 | | -<a href="http://stable.melpa.org/#/phpstan"><img alt="MELPA stable: phpstan" src="http://stable.melpa.org/packages/phpstan-badge.svg"></a> |
| 3 | +<a href="http://melpa.org/#/psalm"><img alt="MELPA: psalm" src="http://melpa.org/packages/psalm-badge.svg"></a> |
| 4 | +<a href="http://stable.melpa.org/#/psalm"><img alt="MELPA stable: psalm" src="http://stable.melpa.org/packages/psalm-badge.svg"></a> |
5 | 5 | #+END_HTML |
6 | | -Emacs interface to [[https://github.com/phpstan/phpstan][PHPStan]], includes checker for [[http://www.flycheck.org/en/latest/][Flycheck]]. |
| 6 | +Emacs interface to [[https://psalm.dev/][Psalm]], includes checker for [[http://www.flycheck.org/en/latest/][Flycheck]]. |
7 | 7 | ** Support version |
8 | 8 | - Emacs 24+ |
9 | | -- PHPStan latest/dev-master (NOT support 0.9 seriese) |
| 9 | +- Psalm latest/dev-master (NOT support 0.9 seriese) |
10 | 10 | - PHP 7.1+ or Docker runtime |
11 | 11 | ** How to install |
12 | 12 | *** Install from MELPA |
13 | 13 | 1. If you have not set up MELPA, see [[https://melpa.org/#/getting-started][Getting Started - MELPA]]. |
14 | | - 2. ~M-x package-install flycheck-phpstan~ |
| 14 | + 2. ~M-x package-install flycheck-psalm~ |
15 | 15 | ** How to use |
16 | 16 | *** For Flycheck user |
17 | 17 | #+BEGIN_SRC emacs-lisp |
18 | 18 | (defun my-php-mode-setup () |
19 | 19 | "My PHP-mode hook." |
20 | | - (require 'flycheck-phpstan) |
| 20 | + (require 'flycheck-psalm) |
21 | 21 | (flycheck-mode t)) |
22 | 22 |
|
23 | 23 | (add-hook 'php-mode-hook 'my-php-mode-setup) |
24 | 24 | #+END_SRC |
25 | 25 |
|
26 | 26 | *** For Flymake user |
27 | 27 | #+BEGIN_SRC emacs-lisp |
28 | | -(add-hook 'php-mode-hook #'flymake-phpstan-turn-on) |
| 28 | +(add-hook 'php-mode-hook #'flymake-psalm-turn-on) |
29 | 29 | #+END_SRC |
30 | 30 |
|
31 | | -*** Using Docker (phpstan/docker-image) |
32 | | -Install [[https://www.docker.com/get-started][Docker]] and [[https://hub.docker.com/r/phpstan/phpstan][phpstan/phpstan image]]. |
| 31 | +*** Using Docker |
| 32 | +Install [[https://www.docker.com/get-started][Docker]]. There is currently no official Docker image we can trust, so if you want to use it, you are at your own risk. |
33 | 33 |
|
34 | | -If you always use Docker for PHPStan, add the following into your ~.emacs~ file (~~/.emacs.d/init.el~) |
| 34 | +If you always use Docker for Psalm, add the following into your ~.emacs~ file (~~/.emacs.d/init.el~) |
35 | 35 | #+BEGIN_SRC emacs-lisp |
36 | | -(setq-default phpstan-executable 'docker) |
| 36 | +;; Be sure to replace it with a Docker image you trust |
| 37 | +(setq-default psalm-docker-image "your/dockerhub-image") |
| 38 | +(setq-default psalm-executable 'docker) |
37 | 39 | #+END_SRC |
38 | 40 |
|
39 | 41 | Put the following into ~.dir-locals.el~ files on the root directory of project. |
40 | 42 | #+BEGIN_SRC emacs-lisp |
41 | 43 | ((nil . ((php-project-root . git) |
42 | | - (phpstan-executable . docker) |
43 | | - (phpstan-working-dir . (root . "path/to/dir")) |
44 | | - (phpstan-config-file . (root . "path/to/dir/phpstan-docker.neon")) |
45 | | - (phpstan-level . 7)))) |
| 44 | + (psalm-executable . docker) |
| 45 | + (psalm-working-dir . (root . "path/to/dir")) |
| 46 | + (psalm-config-file . (root . "path/to/dir/psalm-docker.neon")) |
| 47 | + (psalm-level . 7)))) |
46 | 48 | #+END_SRC |
47 | 49 |
|
48 | 50 | *** Using composer (project specific) |
49 | | -If your project Composer relies on phpstan, you do not need to set anything. |
| 51 | +If your project Composer relies on psalm, you do not need to set anything. |
50 | 52 | #+BEGIN_SRC emacs-lisp |
51 | 53 | ((nil . ((php-project-root . git) |
52 | | - (phpstan-executable . docker) |
53 | | - (phpstan-working-dir . (root . "path/to/dir")) |
54 | | - (phpstan-config-file . (root . "path/to/dir/phpstan-docker.neon")) |
55 | | - (phpstan-level . 7)))) |
| 54 | + (psalm-executable . docker) |
| 55 | + (psalm-working-dir . (root . "path/to/dir")) |
| 56 | + (psalm-config-file . (root . "path/to/dir/psalm-docker.neon")) |
| 57 | + (psalm-level . 7)))) |
56 | 58 | #+END_SRC |
57 | 59 |
|
58 | 60 | *** Using Composer |
59 | | -Please install [[https://packagist.org/packages/phpstan/phpstan][phpstan/phpstan]] package for each user environment or project by using [[https://getcomposer.org/download/][Composer]]. |
| 61 | +Please install [[https://packagist.org/packages/vimeo/psalm][vimeo/psalm]] package for each user environment or project by using [[https://getcomposer.org/download/][Composer]]. |
60 | 62 |
|
61 | 63 | If you are unfamiliar with resolving dependencies, the following shell commands are recommended. |
62 | 64 | #+BEGIN_SRC shell |
63 | | -$ composer global require phpstan/phpstan |
| 65 | +$ composer global require vimeo/psalm |
64 | 66 | #+END_SRC |
65 | 67 |
|
66 | | -*NOTICE*: [[https://packagist.org/packages/phpstan/phpstan-shim][phpstan/phpstan-shim]] is deprecated. Please read [[https://medium.com/@ondrejmirtes/phpstan-0-12-released-f1a88036535d][PHPStan 0.12 Released!]]. |
67 | | - |
68 | 68 | *** Using PHAR archive |
69 | | -*NOTICE*: ~phpstan.el~ requires PHPStan **0.10+**. We *strongly* recommend using the latest PHPStan. |
| 69 | +*NOTICE*: We *strongly* recommend using the latest Psalm. |
70 | 70 |
|
71 | | -Please download ~phpstan.phar~ from [[https://github.com/phpstan/phpstan/releases][Releases · phpstan/phpstan]]. |
| 71 | +Please download ~psalm.phar~ from [[https://github.com/vimeo/psalm/releases][Releases · vimeo/psalm]]. |
72 | 72 | ** Settings |
73 | | -Variables for phpstan are mainly controlled by [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html][directory variables]] (~.dir-locals.el~). |
| 73 | +Variables for psalm are mainly controlled by [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html][directory variables]] (~.dir-locals.el~). |
74 | 74 |
|
75 | 75 | 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. |
76 | 76 |
|
77 | | -Please be aware that the root directory of the PHP project may *NOT* match either of PHPStan's ~%rootDir%~ and/or ~%currentWorkingDirectory%~. |
| 77 | +Please be aware that the root directory of the PHP project may *NOT* match either of Psalm's ~%rootDir%~ and/or ~%currentWorkingDirectory%~. |
78 | 78 |
|
79 | 79 | Typically, you would set the following ~.dir-locals.el~. |
80 | 80 |
|
81 | 81 | #+BEGIN_SRC emacs-lisp |
82 | 82 | ((nil . ((php-project-root . auto) |
83 | | - (phpstan-executable . docker) |
84 | | - (phpstan-working-dir . (root . "path/to/dir/")) |
85 | | - (phpstan-config-file . (root . "path/to/dir/phpstan-custom.neon")) |
86 | | - (phpstan-level . max)))) |
| 83 | + (psalm-executable . docker) |
| 84 | + (psalm-working-dir . (root . "path/to/dir/")) |
| 85 | + (psalm-config-file . (root . "path/to/dir/psalm-custom.neon")) |
| 86 | + (psalm-level . max)))) |
87 | 87 | #+END_SRC |
88 | 88 |
|
89 | | -If there is a ~phpstan.neon~ file in the root directory of the project, you do not need to set both ~phpstan-working-dir~ and ~phpstan-config-file~. |
| 89 | +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~. |
90 | 90 |
|
91 | 91 | ** API |
92 | 92 | Most variables defined in this package are buffer local. If you want to set it for multiple projects, use [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Default-Value.html][setq-default]]. |
93 | 93 |
|
94 | | -*** Local variable ~phpstan-working-dir~ |
95 | | -Path to working directory of PHPStan. |
| 94 | +*** Local variable ~psalm-working-dir~ |
| 95 | +Path to working directory of Psalm. |
96 | 96 |
|
97 | | -- STRING :: Absolute path to `phpstan' working directory. |
98 | | - - ex) ~"/path/to/phpstan.phar"~ |
99 | | -- ~(root . STRING)~ :: Relative path to `phpstan' working directory from project root directory. |
| 97 | +- STRING :: Absolute path to `psalm' working directory. |
| 98 | + - ex) ~"/path/to/psalm.phar"~ |
| 99 | +- ~(root . STRING)~ :: Relative path to `psalm' working directory from project root directory. |
100 | 100 | - ex) ~(root . "path/to/dir")~ |
101 | 101 | - ~nil~ :: Use ~(php-project-get-root-dir)~ as working directory. |
102 | 102 |
|
103 | | -*** Local variable ~phpstan-config-file~ |
104 | | -Path to project specific configuration file of PHPStan. |
| 103 | +*** Local variable ~psalm-config-file~ |
| 104 | +Path to project specific configuration file of Psalm. |
105 | 105 |
|
106 | | -- STRING :: Absolute path to ~phpstan~ configuration file. |
107 | | -- ~(root . STRING)~ :: Relative path to ~phpstan~ configuration file from project root directory. |
108 | | -- NIL :: Search ~phpstan.neon(.dist)~ in ~(phpstan-get-working-dir)~. |
| 106 | +- STRING :: Absolute path to ~psalm~ configuration file. |
| 107 | +- ~(root . STRING)~ :: Relative path to ~psalm~ configuration file from project root directory. |
| 108 | +- NIL :: Search ~psalm.neon(.dist)~ in ~(psalm-get-working-dir)~. |
109 | 109 |
|
110 | | -*** Local variable ~phpstan-level~ |
111 | | -Rule level of PHPStan analysis. Please see [[https://github.com/phpstan/phpstan/blob/master/README.md#rule-levels][README #Rule levels of PHPStan]]. |
| 110 | +*** Local variable ~psalm-level~ |
| 111 | +Rule level of Psalm analysis. Please see [[https://github.com/vimeo/psalm/blob/master/README.md#rule-levels][README #Rule levels of Psalm]]. |
112 | 112 | ~0~ is the loosest and you can also use ~max~ as an alias for the highest level. Default level is ~0~. |
113 | 113 |
|
114 | | -*** Local variable ~phpstan-executable~ |
115 | | -- STRING :: Absolute path to `phpstan' executable file. |
116 | | - - ex) ~"/path/to/phpstan.phar"~ |
117 | | -- SYMBOL ~docker~ :: Use Docker using phpstan/docker-image. |
118 | | -- ~(root . STRING)~ :: Relative path to `phpstan' executable file from project root directory. |
119 | | - - ex) ~(root . "script/phpstan")~ |
| 114 | +*** Local variable ~psalm-executable~ |
| 115 | +- STRING :: Absolute path to `psalm' executable file. |
| 116 | + - ex) ~"/path/to/psalm.phar"~ |
| 117 | +- SYMBOL ~docker~ :: Use Docker using psalm/docker-image. |
| 118 | +- ~(root . STRING)~ :: Relative path to `psalm' executable file from project root directory. |
| 119 | + - ex) ~(root . "script/psalm")~ |
120 | 120 | - ~(STRING . (ARGUMENTS ...))~ :: Command name and arguments. |
121 | 121 | - ex) ~("docker" "run" "--rm" "-v" "/path/to/project-dir/:/app" "your/docker-image")~ |
122 | | -- ~nil~ :: Auto detect ~phpstan~ executable file by composer dependencies of the project or executable command in ~PATH~ environment variable. |
| 122 | +- ~nil~ :: Auto detect ~psalm~ executable file by composer dependencies of the project or executable command in ~PATH~ environment variable. |
123 | 123 |
|
124 | | -*** Custom variable ~phpstan-flycheck-auto-set-executable~ |
125 | | -Set flycheck phpstan-executable automatically when non-NIL. |
| 124 | +*** Custom variable ~psalm-flycheck-auto-set-executable~ |
| 125 | +Set flycheck psalm-executable automatically when non-NIL. |
0 commit comments