• Stars
    star
    395
  • Rank 109,040 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 5 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Composer plugin for automatic installation of PHPStan extensions.

PHPStan Extension Installer

Build Latest Stable Version License

Composer plugin for automatic installation of PHPStan extensions.

Motivation

diff --git a/phpstan.neon b/phpstan.neon
index db4e3df32e..2ca30fa20a 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,12 +1,3 @@
-includes:
-	- vendor/phpstan/phpstan-doctrine/extension.neon
-	- vendor/phpstan/phpstan-doctrine/rules.neon
-	- vendor/phpstan/phpstan-nette/extension.neon
-	- vendor/phpstan/phpstan-nette/rules.neon
-	- vendor/phpstan/phpstan-phpunit/extension.neon
-	- vendor/phpstan/phpstan-phpunit/rules.neon
-	- vendor/phpstan/phpstan-strict-rules/rules.neon
-
 parameters:
 	autoload_directories:
 		- %rootDir%/../../../build/SlevomatSniffs
diff --git a/composer.json b/composer.json
index 1b578dd624..f6ebf6e477 100644
--- a/composer.json
+++ b/composer.json
@@ -142,6 +142,7 @@
 		"jakub-onderka/php-parallel-lint": "1.0.0",
 		"justinrainbow/json-schema": "5.2.8",
 		"ondrejmirtes/mocktainer": "0.8",
+		"phpstan/extension-installer": "^1.0",
 		"phpstan/phpstan": "^0.11.7",
 		"phpstan/phpstan-doctrine": "^0.11.3",
 		"phpstan/phpstan-nette": "^0.11.1",

Usage

composer require --dev phpstan/extension-installer

Starting from Composer 2.2.0 you'll get the following question:

phpstan/extension-installer contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "phpstan/extension-installer" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?]

Answer with y to allow the plugin.

Instructions for extension developers

It's best (but optional) to set the extension's composer package type to phpstan-extension for this plugin to be able to recognize it and to be discoverable on Packagist.

Add phpstan key in the extension composer.json's extra section:

{
  "extra": {
    "phpstan": {
      "includes": [
        "extension.neon"
      ]
    }
  }
}

Ignoring a particular extension

You may want to disable auto-installation of a particular extension to handle installation manually. Ignore an extension by adding an extra.phpstan/extension-installer.ignore array in composer.json that specifies a list of packages to ignore:

{
  "extra": {
    "phpstan/extension-installer": {
      "ignore": [
        "phpstan/phpstan-phpunit"
      ]
    }
  }
}

Limitations

The extension installer depends on Composer script events, therefore you cannot use --no-scripts flag.

More Repositories

1

phpstan

PHP Static Analysis Tool - discover bugs in your code without running it!
PHP
12,763
star
2

phpdoc-parser

Next-gen phpDoc parser with support for intersection types and generics
PHP
1,303
star
3

phpstan-symfony

Symfony extension for PHPStan
PHP
691
star
4

phpstan-strict-rules

Extra strict and opinionated rules for PHPStan
PHP
586
star
5

phpstan-doctrine

Doctrine extensions for PHPStan
PHP
577
star
6

phpstan-phpunit

PHPUnit extensions and rules for PHPStan
PHP
450
star
7

phpstan-deprecation-rules

PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.
PHP
360
star
8

phpstan-src

PHPStan's source code. This is where development happens. Check https://github.com/phpstan/phpstan for the distribution repository.
PHP
307
star
9

phpstan-webmozart-assert

PHPStan extension for webmozart/assert
PHP
160
star
10

phpstan-nette

Nette Framework class reflection extension for PHPStan & framework-specific rules
PHP
100
star
11

phpstan-shim

[DEPRECATED] This repository provides easy way to install PHPStan without the risk of conflicting dependencies.
PHP
87
star
12

phpstan-mockery

PHPStan extension for Mockery
PHP
81
star
13

phpstan-beberlei-assert

PHPStan extension for beberlei/assert
PHP
38
star
14

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.
PHP
29
star
15

php-8-stubs

PHP
27
star
16

phpstan-php-parser

PHP-Parser extension for PHPStan
Makefile
23
star
17

phpstan-dibi

Dibi class reflection extension for PHPStan
PHP
15
star
18

build-cs

Coding standard for 1st party PHPStan extensions
2
star