All Projects → emacs-php → phpstan.el

emacs-php / phpstan.el

Licence: GPL-3.0 license
Interface to PHPStan (PHP static analyzer)

Programming Languages

emacs lisp
2029 projects
Makefile
30231 projects
PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to phpstan.el

flycheck-elsa
Flycheck integration for Elsa---Emacs lisp static analyzer
Stars: ✭ 25 (+13.64%)
Mutual labels:  static-analysis, flycheck
phpstan-webmozart-assert
PHPStan extension for webmozart/assert
Stars: ✭ 132 (+500%)
Mutual labels:  static-analysis
nestif
Detect deeply nested if statements in Go source code
Stars: ✭ 30 (+36.36%)
Mutual labels:  static-analysis
awesome-malware-analysis
Defund the Police.
Stars: ✭ 9,181 (+41631.82%)
Mutual labels:  static-analysis
save-cloud
Cluster-based cloud mechanism for running SAVE framework
Stars: ✭ 30 (+36.36%)
Mutual labels:  static-analysis
jitana
A graph-based static-dynamic hybrid DEX code analysis tool
Stars: ✭ 35 (+59.09%)
Mutual labels:  static-analysis
sonar-css-plugin
SonarQube CSS / SCSS / Less Analyzer
Stars: ✭ 46 (+109.09%)
Mutual labels:  static-analysis
go-mnd
Magic number detector for Go.
Stars: ✭ 153 (+595.45%)
Mutual labels:  static-analysis
sonarlint4netbeans
SonarLint integration for Apache Netbeans
Stars: ✭ 23 (+4.55%)
Mutual labels:  static-analysis
phpstan-nette
Nette Framework class reflection extension for PHPStan & framework-specific rules
Stars: ✭ 87 (+295.45%)
Mutual labels:  static-analysis
klara
Automatic test case generation for python and static analysis library
Stars: ✭ 250 (+1036.36%)
Mutual labels:  static-analysis
logifix
Fixing static analysis violations in Java source code using Datalog
Stars: ✭ 17 (-22.73%)
Mutual labels:  static-analysis
sonar-scala
A free and open-source SonarQube plugin for static code analysis of Scala projects.
Stars: ✭ 113 (+413.64%)
Mutual labels:  static-analysis
vim-phpstan
A Vim plugin for PHPStan - https://github.com/phpstan/phpstan. It calls `phpstan` to do static analysis of your PHP code and displays the errors in Vim's quickfix list.
Stars: ✭ 26 (+18.18%)
Mutual labels:  static-analysis
rstatic
An R package for static analysis of R code.
Stars: ✭ 32 (+45.45%)
Mutual labels:  static-analysis
gqlanalysis
gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.
Stars: ✭ 36 (+63.64%)
Mutual labels:  static-analysis
phpstan
PHP Static Analysis in Github Actions.
Stars: ✭ 41 (+86.36%)
Mutual labels:  static-analysis
mllint
`mllint` is a command-line utility to evaluate the technical quality of Python Machine Learning (ML) projects by means of static analysis of the project's repository.
Stars: ✭ 67 (+204.55%)
Mutual labels:  static-analysis
unimport
unimport is a Go static analysis tool to find unnecessary import aliases.
Stars: ✭ 64 (+190.91%)
Mutual labels:  static-analysis
deps-infer
Infer mvn deps from sources
Stars: ✭ 36 (+63.64%)
Mutual labels:  static-analysis

phpstan.el

MELPA: phpstan MELPA stable: phpstan

Emacs interface to PHPStan, includes checker for Flycheck.

Support version

  • Emacs 24+
  • PHPStan 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-phpstan

How to use

For Flycheck user

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

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

For Flymake user

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

Using Docker (phpstan/docker-image)

Install Docker and phpstan/phpstan image.

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

(setq-default phpstan-executable 'docker)

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

((nil . ((php-project-root . git)
         (phpstan-executable . docker)
         (phpstan-working-dir . (root . "path/to/dir"))
         (phpstan-config-file . (root . "path/to/dir/phpstan-docker.neon"))
	 (phpstan-memory-limit . "1G")
         (phpstan-level . 7))))

Using composer (project specific)

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

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

Using Composer

Please install phpstan/phpstan 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 phpstan/phpstan

NOTICE: phpstan/phpstan-shim is deprecated. Please read PHPStan 0.12 Released!.

Using PHAR archive

NOTICE: phpstan.el requires PHPStan **0.10+**. We strongly recommend using the latest PHPStan.

Please download phpstan.phar from Releases · phpstan/phpstan.

Settings

Variables for phpstan 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 PHPStan’s %rootDir% and/or %currentWorkingDirectory%.

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

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

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.

API

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

Local variable phpstan-working-dir

Path to working directory of PHPStan.

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

Local variable phpstan-config-file

Path to project specific configuration file of PHPStan.

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

Local variable phpstan-level

Rule level of PHPStan analysis. Please see README #Rule levels of PHPStan. 0 is the loosest and you can also use max as an alias for the highest level. Default level is 0.

Local variable phpstan-executable

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

Custom variable phpstan-flycheck-auto-set-executable

Set flycheck phpstan-executable automatically when non-NIL.

Custom variable phpstan-memory-limit

Use phpstan memory limit option when non-NIL.

STRING
Specifies the memory limit in the same format php.ini accepts.
  • ex) ~”1G”~
nil
Use memory limit in php.ini

Custom variable phpstan-docker-image

Docker image URL or Docker Hub image name or NIL. Default as ~”ghcr.io/phpstan/phpstan”~. See Docker - PHPStan Documentation and GitHub Container Registory - Package phpstan.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].