phpstan/extension-installer

用于自动安装PHPStan扩展的Composer插件

安装次数: 50,433,866

依赖项: 5,806

建议者: 4

安全性: 0

星标: 406

关注者: 6

分支: 27

开放问题: 4

类型:composer-plugin

1.4.3 2024-09-04 20:21 UTC

This package is auto-updated.

Last update: 2024-09-06 14:27:30 UTC


README

Build Latest Stable Version License

用于自动安装PHPStan扩展的Composer插件。

动机

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",

用法

composer require --dev phpstan/extension-installer

从Composer 2.2.0版本开始,您将看到以下提示

phpstan/extension-installer contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org.cn/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,?]

使用 y 响应以允许插件。

扩展开发者的说明

对于此插件能够识别并能在Packagist上找到(可选但推荐)最好将扩展的composer包类型设置为phpstan-extension

在扩展的composer.json文件的extra部分添加phpstan

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

忽略特定的扩展

您可能想要禁用特定扩展的自动安装以手动处理安装。在composer.json中添加一个extra.phpstan/extension-installer.ignore数组来忽略特定的扩展,该数组指定要忽略的包列表。

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

限制

扩展安装器依赖于Composer脚本事件,因此您不能使用--no-scripts标志。