|
| 1 | +;;; phpstan.el --- Interface to PHPStan. -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2018 Friends of Emacs-PHP development |
| 4 | + |
| 5 | +;; Author: USAMI Kenta <tadsan@zonu.me> |
| 6 | +;; Created: 15 Mar 2018 |
| 7 | +;; Version: 0.0.1 |
| 8 | +;; Keywords: tools, php |
| 9 | +;; Homepage: https://github.com/emacs-php/phpstan.el |
| 10 | +;; Package-Requires: ((emacs "24")) |
| 11 | + |
| 12 | +;; This program is free software; you can redistribute it and/or modify |
| 13 | +;; it under the terms of the GNU General Public License as published by |
| 14 | +;; the Free Software Foundation, either version 3 of the License, or |
| 15 | +;; (at your option) any later version. |
| 16 | + |
| 17 | +;; This program is distributed in the hope that it will be useful, |
| 18 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +;; GNU General Public License for more details. |
| 21 | + |
| 22 | +;; You should have received a copy of the GNU General Public License |
| 23 | +;; along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 24 | + |
| 25 | +;;; Commentary: |
| 26 | + |
| 27 | +;; Static analyze for PHP code using PHPStan. |
| 28 | +;; https://github.com/phpstan/phpstan |
| 29 | + |
| 30 | +;;; Code: |
| 31 | +(require 'flycheck nil) |
| 32 | + |
| 33 | +;;;###autoload |
| 34 | +(when (featurep 'flycheck) |
| 35 | + (flycheck-define-checker phpstan-checker |
| 36 | + "PHP static analyzer based on PHPStan." |
| 37 | + :command ("phpstan" "analyze" "--errorFormat=raw" source) |
| 38 | + :working-directory (lambda (_) (php-project-get-root-dir)) |
| 39 | + :enabled (lambda () (locate-dominating-file "phpstan.neon" default-directory)) |
| 40 | + :error-patterns |
| 41 | + ((error line-start (1+ (not (any ":"))) ":" line ":" (message) line-end)) |
| 42 | + :modes (php-mode) |
| 43 | + :next-checkers (php))) |
| 44 | + |
| 45 | +(provide 'phpstan) |
| 46 | +;;; phpstan.el ends here |
0 commit comments