add phpstan strict
This commit is contained in:
21
vendor/phpstan/extension-installer/LICENSE
vendored
Normal file
21
vendor/phpstan/extension-installer/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Ondřej Mirtes
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
77
vendor/phpstan/extension-installer/README.md
vendored
Normal file
77
vendor/phpstan/extension-installer/README.md
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# PHPStan Extension Installer
|
||||
|
||||
[](https://github.com/phpstan/extension-installer/actions)
|
||||
[](https://packagist.org/packages/phpstan/extension-installer)
|
||||
[](https://packagist.org/packages/phpstan/extension-installer)
|
||||
|
||||
Composer plugin for automatic installation of [PHPStan](https://phpstan.org/) extensions.
|
||||
|
||||
# Motivation
|
||||
|
||||
```diff
|
||||
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
|
||||
|
||||
```bash
|
||||
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](https://getcomposer.org/doc/04-schema.md#type) to `phpstan-extension` for this plugin to be able to recognize it and to be [discoverable on Packagist](https://packagist.org/explore/?type=phpstan-extension).
|
||||
|
||||
Add `phpstan` key in the extension `composer.json`'s `extra` section:
|
||||
|
||||
```json
|
||||
{
|
||||
"extra": {
|
||||
"phpstan": {
|
||||
"includes": [
|
||||
"extension.neon"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Limitations
|
||||
|
||||
The extension installer depends on Composer script events, therefore you cannot use `--no-scripts` flag.
|
||||
12
vendor/phpstan/extension-installer/build-cs/composer.json
vendored
Normal file
12
vendor/phpstan/extension-installer/build-cs/composer.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"require-dev": {
|
||||
"consistence-community/coding-standard": "^3.10",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"slevomat/coding-standard": "^7.0"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
322
vendor/phpstan/extension-installer/build-cs/composer.lock
generated
vendored
Normal file
322
vendor/phpstan/extension-installer/build-cs/composer.lock
generated
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "4485bbedba7bcc71ace5f69dbb9b6c47",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "consistence-community/coding-standard",
|
||||
"version": "3.11.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/consistence-community/coding-standard.git",
|
||||
"reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/4632fead8c9ee8f50044fcbce9f66c797b34c0df",
|
||||
"reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.4",
|
||||
"slevomat/coding-standard": "~7.0",
|
||||
"squizlabs/php_codesniffer": "~3.6.0"
|
||||
},
|
||||
"replace": {
|
||||
"consistence/coding-standard": "3.10.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "2.16.4",
|
||||
"php-parallel-lint/php-parallel-lint": "1.3.0",
|
||||
"phpunit/phpunit": "9.5.4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Consistence\\": [
|
||||
"Consistence"
|
||||
]
|
||||
},
|
||||
"classmap": [
|
||||
"Consistence"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Vašek Purchart",
|
||||
"email": "me@vasekpurchart.cz",
|
||||
"homepage": "http://vasekpurchart.cz"
|
||||
}
|
||||
],
|
||||
"description": "Consistence - Coding Standard - PHP Code Sniffer rules",
|
||||
"keywords": [
|
||||
"Coding Standard",
|
||||
"PHPCodeSniffer",
|
||||
"codesniffer",
|
||||
"coding",
|
||||
"cs",
|
||||
"phpcs",
|
||||
"ruleset",
|
||||
"sniffer",
|
||||
"standard"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/consistence-community/coding-standard/issues",
|
||||
"source": "https://github.com/consistence-community/coding-standard/tree/3.11.1"
|
||||
},
|
||||
"time": "2021-05-03T18:13:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dealerdirect/phpcodesniffer-composer-installer",
|
||||
"version": "v0.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
|
||||
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
|
||||
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0 || ^2.0",
|
||||
"php": ">=5.3",
|
||||
"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "*",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3.1",
|
||||
"phpcompatibility/php-compatibility": "^9.0"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Franck Nijhof",
|
||||
"email": "franck.nijhof@dealerdirect.com",
|
||||
"homepage": "http://www.frenck.nl",
|
||||
"role": "Developer / IT Manager"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
|
||||
"homepage": "http://www.dealerdirect.com",
|
||||
"keywords": [
|
||||
"PHPCodeSniffer",
|
||||
"PHP_CodeSniffer",
|
||||
"code quality",
|
||||
"codesniffer",
|
||||
"composer",
|
||||
"installer",
|
||||
"phpcbf",
|
||||
"phpcs",
|
||||
"plugin",
|
||||
"qa",
|
||||
"quality",
|
||||
"standard",
|
||||
"standards",
|
||||
"style guide",
|
||||
"stylecheck",
|
||||
"tests"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
|
||||
"source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
|
||||
},
|
||||
"time": "2022-02-04T12:51:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpdoc-parser",
|
||||
"version": "1.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
||||
"reference": "981cc368a216c988e862a75e526b6076987d1b50"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50",
|
||||
"reference": "981cc368a216c988e862a75e526b6076987d1b50",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||
"phpstan/extension-installer": "^1.0",
|
||||
"phpstan/phpstan": "^1.5",
|
||||
"phpstan/phpstan-strict-rules": "^1.0",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/process": "^5.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PHPStan\\PhpDocParser\\": [
|
||||
"src/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
|
||||
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1"
|
||||
},
|
||||
"time": "2022-05-05T11:32:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "slevomat/coding-standard",
|
||||
"version": "7.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slevomat/coding-standard.git",
|
||||
"reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90",
|
||||
"reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
|
||||
"php": "^7.2 || ^8.0",
|
||||
"phpstan/phpdoc-parser": "^1.5.1",
|
||||
"squizlabs/php_codesniffer": "^3.6.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "2.17.3",
|
||||
"php-parallel-lint/php-parallel-lint": "1.3.2",
|
||||
"phpstan/phpstan": "1.4.10|1.7.1",
|
||||
"phpstan/phpstan-deprecation-rules": "1.0.0",
|
||||
"phpstan/phpstan-phpunit": "1.0.0|1.1.1",
|
||||
"phpstan/phpstan-strict-rules": "1.2.3",
|
||||
"phpunit/phpunit": "7.5.20|8.5.21|9.5.20"
|
||||
},
|
||||
"type": "phpcodesniffer-standard",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SlevomatCodingStandard\\": "SlevomatCodingStandard"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
|
||||
"support": {
|
||||
"issues": "https://github.com/slevomat/coding-standard/issues",
|
||||
"source": "https://github.com/slevomat/coding-standard/tree/7.2.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/kukulich",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-05-25T10:58:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.6.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||
"reference": "5e4e71592f69da17871dba6e80dd51bce74a351a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a",
|
||||
"reference": "5e4e71592f69da17871dba6e80dd51bce74a351a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-simplexml": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/phpcs",
|
||||
"bin/phpcbf"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Sherwood",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
|
||||
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"keywords": [
|
||||
"phpcs",
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
|
||||
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
|
||||
},
|
||||
"time": "2021-12-12T21:44:58+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
32
vendor/phpstan/extension-installer/composer.json
vendored
Normal file
32
vendor/phpstan/extension-installer/composer.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "phpstan/extension-installer",
|
||||
"type": "composer-plugin",
|
||||
"description": "Composer plugin for automatic installation of PHPStan extensions",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0",
|
||||
"composer-plugin-api": "^2.0",
|
||||
"phpstan/phpstan": "^1.8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "^2.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.2.0",
|
||||
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"ocramius/package-versions": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"class": "PHPStan\\ExtensionInstaller\\Plugin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PHPStan\\ExtensionInstaller\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
26
vendor/phpstan/extension-installer/src/GeneratedConfig.php
vendored
Normal file
26
vendor/phpstan/extension-installer/src/GeneratedConfig.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace PHPStan\ExtensionInstaller;
|
||||
|
||||
/**
|
||||
* This is a stub class: it is in place only for scenarios where Composer
|
||||
* is run with a `--no-scripts` flag, in which scenarios this stub class
|
||||
* is not being replaced.
|
||||
*
|
||||
* If you are reading this docBlock inside your `vendor/` dir, then this means
|
||||
* that phpstan/extension-installer didn't correctly install.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
|
||||
public const EXTENSIONS = [];
|
||||
|
||||
public const NOT_INSTALLED = [];
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
159
vendor/phpstan/extension-installer/src/Plugin.php
vendored
Normal file
159
vendor/phpstan/extension-installer/src/Plugin.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace PHPStan\ExtensionInstaller;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
use Composer\Script\Event;
|
||||
use Composer\Script\ScriptEvents;
|
||||
use Composer\Util\Filesystem;
|
||||
use function array_keys;
|
||||
use function dirname;
|
||||
use function file_exists;
|
||||
use function file_put_contents;
|
||||
use function getcwd;
|
||||
use function in_array;
|
||||
use function is_file;
|
||||
use function ksort;
|
||||
use function md5;
|
||||
use function md5_file;
|
||||
use function sprintf;
|
||||
use function strpos;
|
||||
use function var_export;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
final class Plugin implements PluginInterface, EventSubscriberInterface
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private static $generatedFileTemplate = <<<'PHP'
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace PHPStan\ExtensionInstaller;
|
||||
|
||||
/**
|
||||
* This class is generated by phpstan/extension-installer.
|
||||
* @internal
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
|
||||
public const EXTENSIONS = %s;
|
||||
|
||||
public const NOT_INSTALLED = %s;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PHP;
|
||||
|
||||
public function activate(Composer $composer, IOInterface $io): void
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
public function deactivate(Composer $composer, IOInterface $io): void
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
public function uninstall(Composer $composer, IOInterface $io): void
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
ScriptEvents::POST_INSTALL_CMD => 'process',
|
||||
ScriptEvents::POST_UPDATE_CMD => 'process',
|
||||
];
|
||||
}
|
||||
|
||||
public function process(Event $event): void
|
||||
{
|
||||
$io = $event->getIO();
|
||||
|
||||
if (!file_exists(__DIR__)) {
|
||||
$io->write('<info>phpstan/extension-installer:</info> Package not found (probably scheduled for removal); extensions installation skipped.');
|
||||
return;
|
||||
}
|
||||
|
||||
$composer = $event->getComposer();
|
||||
$installationManager = $composer->getInstallationManager();
|
||||
|
||||
$generatedConfigFilePath = __DIR__ . '/GeneratedConfig.php';
|
||||
$oldGeneratedConfigFileHash = null;
|
||||
if (is_file($generatedConfigFilePath)) {
|
||||
$oldGeneratedConfigFileHash = md5_file($generatedConfigFilePath);
|
||||
}
|
||||
$notInstalledPackages = [];
|
||||
$installedPackages = [];
|
||||
|
||||
$data = [];
|
||||
$fs = new Filesystem();
|
||||
foreach ($composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
|
||||
if (
|
||||
$package->getType() !== 'phpstan-extension'
|
||||
&& !isset($package->getExtra()['phpstan'])
|
||||
) {
|
||||
if (
|
||||
strpos($package->getName(), 'phpstan') !== false
|
||||
&& !in_array($package->getName(), [
|
||||
'phpstan/phpstan',
|
||||
'phpstan/phpstan-shim',
|
||||
'phpstan/phpdoc-parser',
|
||||
'phpstan/extension-installer',
|
||||
], true)
|
||||
) {
|
||||
$notInstalledPackages[$package->getName()] = $package->getFullPrettyVersion();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$installPath = $installationManager->getInstallPath($package);
|
||||
|
||||
$absoluteInstallPath = $fs->isAbsolutePath($installPath)
|
||||
? $installPath
|
||||
: getcwd() . DIRECTORY_SEPARATOR . $installPath;
|
||||
|
||||
$data[$package->getName()] = [
|
||||
'install_path' => $absoluteInstallPath,
|
||||
'relative_install_path' => $fs->findShortestPath(dirname($generatedConfigFilePath), $absoluteInstallPath, true),
|
||||
'extra' => $package->getExtra()['phpstan'] ?? null,
|
||||
'version' => $package->getFullPrettyVersion(),
|
||||
];
|
||||
|
||||
$installedPackages[$package->getName()] = true;
|
||||
}
|
||||
|
||||
ksort($data);
|
||||
ksort($installedPackages);
|
||||
ksort($notInstalledPackages);
|
||||
|
||||
$generatedConfigFileContents = sprintf(self::$generatedFileTemplate, var_export($data, true), var_export($notInstalledPackages, true));
|
||||
file_put_contents($generatedConfigFilePath, $generatedConfigFileContents);
|
||||
$io->write('<info>phpstan/extension-installer:</info> Extensions installed');
|
||||
|
||||
if ($oldGeneratedConfigFileHash === md5($generatedConfigFileContents)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (array_keys($installedPackages) as $name) {
|
||||
$io->write(sprintf('> <info>%s:</info> installed', $name));
|
||||
}
|
||||
|
||||
foreach (array_keys($notInstalledPackages) as $name) {
|
||||
$io->write(sprintf('> <comment>%s:</comment> not supported', $name));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user