Skip to content
Composer plugin for automatic installation of PHPStan extensions.
PHP
Branch: master
Clone or download
jdeniau and ondrejmirtes Don't force the package type
phpstan/extension-installer will work if the package type is
`phpstan-extension` or if the `extra.phpstan.includes` key is
configured.
Latest commit 2956567 Oct 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Don't force the package type Oct 18, 2019
.gitignore Remove GeneratedConfig from VCS so that Composer does not prompt disc… May 13, 2019
.travis.yml Build May 19, 2019
LICENSE License May 19, 2019
README.md Don't force the package type Oct 18, 2019
build.xml Build May 19, 2019
composer.json License May 19, 2019
phpcs.xml Build May 19, 2019
phpstan.neon Build May 19, 2019

README.md

PHPStan Extension Installer

Build Status 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

And that's it.

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.

Only one feature is supported right now: PHPStan is able to automatically include the extension's config files, without you having to mention them in your phpstan.neon's includes section.

For this, you have to add a phpstan key in the extension composer.json's extra section like so:

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

Limitations

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

You can’t perform that action at this time.