120
vendor/composer/package-versions-deprecated/CHANGELOG.md
vendored
Normal file
120
vendor/composer/package-versions-deprecated/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.1.3 - 2017-09-06
|
||||
|
||||
This release fixes a bug that caused PackageVersions to prevent
|
||||
the `composer remove` and `composer update` commands to fail when
|
||||
this package is removed.
|
||||
|
||||
In addition to that, mutation testing has been added to the suite,
|
||||
ensuring that the package is accurately and extensively tested.
|
||||
|
||||
Total issues resolved: **3**
|
||||
|
||||
- [40: Mutation testing, PHP 7.1 testing](https://github.com/Ocramius/PackageVersions/pull/40) thanks to @Ocramius
|
||||
- [41: Removing this package on install results in file access error](https://github.com/Ocramius/PackageVersions/issues/41) thanks to @Xerkus
|
||||
- [46: #41 Avoid issues when the package is scheduled for removal](https://github.com/Ocramius/PackageVersions/pull/46) thanks to @Jean85
|
||||
|
||||
## 1.1.2 - 2016-12-30
|
||||
|
||||
This release fixes a bug that caused PackageVersions to be enabled
|
||||
even when it was part of a globally installed package.
|
||||
|
||||
Total issues resolved: **3**
|
||||
|
||||
- [35: remove all temp directories](https://github.com/Ocramius/PackageVersions/pull/35)
|
||||
- [38: Interferes with other projects when installed globally](https://github.com/Ocramius/PackageVersions/issues/38)
|
||||
- [39: Ignore the global plugin when updating local projects](https://github.com/Ocramius/PackageVersions/pull/39)
|
||||
|
||||
## 1.1.1 - 2016-07-25
|
||||
|
||||
This release removes the [`"files"`](https://getcomposer.org/doc/04-schema.md#files) directive from
|
||||
[`composer.json`](https://github.com/Ocramius/PackageVersions/commit/86f2636f7c5e7b56fa035fa3826d5fcf80b6dc72),
|
||||
as it is no longer needed for `composer install --classmap-authoritative`.
|
||||
Also, that directive was causing issues with HHVM installations, since
|
||||
PackageVersions is not compatible with it.
|
||||
|
||||
Total issues resolved: **1**
|
||||
|
||||
- [34: Fatal error during travis build after update to 1.1.0](https://github.com/Ocramius/PackageVersions/issues/34)
|
||||
|
||||
## 1.1.0 - 2016-07-22
|
||||
|
||||
This release introduces support for running `composer install --classmap-authoritative`
|
||||
and `composer install --no-scripts`. Please note that performance
|
||||
while using these modes may be degraded, but the package will
|
||||
still work.
|
||||
|
||||
Additionally, the package was tuned to prevent the plugin from
|
||||
running twice at installation.
|
||||
|
||||
Total issues resolved: **10**
|
||||
|
||||
- [18: Fails when using composer install --no-scripts](https://github.com/Ocramius/PackageVersions/issues/18)
|
||||
- [20: CS (spacing)](https://github.com/Ocramius/PackageVersions/pull/20)
|
||||
- [22: Document the way the require-dev section is treated](https://github.com/Ocramius/PackageVersions/issues/22)
|
||||
- [23: Underline that composer.lock is used as source of information](https://github.com/Ocramius/PackageVersions/pull/23)
|
||||
- [27: Fix incompatibility with --classmap-authoritative](https://github.com/Ocramius/PackageVersions/pull/27)
|
||||
- [29: mention optimize-autoloader composer.json config option in README](https://github.com/Ocramius/PackageVersions/pull/29)
|
||||
- [30: The version class is generated twice during composer update](https://github.com/Ocramius/PackageVersions/issues/30)
|
||||
- [31: Remove double registration of the event listeners](https://github.com/Ocramius/PackageVersions/pull/31)
|
||||
- [32: Update the usage of mock APIs to use the new API](https://github.com/Ocramius/PackageVersions/pull/32)
|
||||
- [33: Fix for #18 - support running with --no-scripts flag](https://github.com/Ocramius/PackageVersions/pull/33)
|
||||
|
||||
## 1.0.4 - 2016-04-23
|
||||
|
||||
This release includes a fix/workaround for composer/composer#5237,
|
||||
which causes `ocramius/package-versions` to sometimes generate a
|
||||
`Versions` class with malformed name (something like
|
||||
`Versions_composer_tmp0`) when running `composer require <package-name>`.
|
||||
|
||||
Total issues resolved: **2**
|
||||
|
||||
- [16: Workaround for composer/composer#5237 - class parsing](https://github.com/Ocramius/PackageVersions/pull/16)
|
||||
- [17: Weird Class name being generated](https://github.com/Ocramius/PackageVersions/issues/17)
|
||||
|
||||
## 1.0.3 - 2016-02-26
|
||||
|
||||
This release fixes an issue related to concurrent autoloader
|
||||
re-generation caused by multiple composer plugins being installed.
|
||||
The issue was solved by removing autoloader re-generation from this
|
||||
package, but it may still affect other packages.
|
||||
|
||||
It is now recommended that you run `composer dump-autoload --optimize`
|
||||
after installation when using this particular package.
|
||||
Please note that `composer (install|update) -o` is not sufficient
|
||||
to avoid autoload overhead when using this particular package.
|
||||
|
||||
Total issues resolved: **1**
|
||||
|
||||
- [15: Remove autoload re-dump optimization](https://github.com/Ocramius/PackageVersions/pull/15)
|
||||
|
||||
## 1.0.2 - 2016-02-24
|
||||
|
||||
This release fixes issues related to installing the component without
|
||||
any dev dependencies or with packages that don't have a source or dist
|
||||
reference, which is usual with packages defined directly in the
|
||||
`composer.json`.
|
||||
|
||||
Total issues resolved: **3**
|
||||
|
||||
- [11: fix composer install --no-dev PHP7](https://github.com/Ocramius/PackageVersions/pull/11)
|
||||
- [12: Packages don't always have a source/reference](https://github.com/Ocramius/PackageVersions/issues/12)
|
||||
- [13: Fix #12 - support dist and missing package version references](https://github.com/Ocramius/PackageVersions/pull/13)
|
||||
|
||||
## 1.0.1 - 2016-02-01
|
||||
|
||||
This release fixes an issue related with composer updates to
|
||||
already installed versions.
|
||||
Using `composer require` within a package that already used
|
||||
`ocramius/package-versions` caused the installation to be unable
|
||||
to write the `PackageVersions\Versions` class to a file.
|
||||
|
||||
Total issues resolved: **6**
|
||||
|
||||
- [2: remove unused use statement](https://github.com/Ocramius/PackageVersions/pull/2)
|
||||
- [3: Remove useless files from dist package](https://github.com/Ocramius/PackageVersions/pull/3)
|
||||
- [5: failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly](https://github.com/Ocramius/PackageVersions/issues/5)
|
||||
- [6: Fix/#5 use composer vendor dir](https://github.com/Ocramius/PackageVersions/pull/6)
|
||||
- [7: Hotfix - #5 generate package versions also when in phar context](https://github.com/Ocramius/PackageVersions/pull/7)
|
||||
- [8: Versions class should be ignored by VCS, as it is an install-time artifact](https://github.com/Ocramius/PackageVersions/pull/8)
|
||||
39
vendor/composer/package-versions-deprecated/CONTRIBUTING.md
vendored
Normal file
39
vendor/composer/package-versions-deprecated/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
title: Contributing
|
||||
---
|
||||
|
||||
# Contributing
|
||||
|
||||
* Coding standard for the project is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
|
||||
* The project will follow strict [object calisthenics](http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php)
|
||||
* Any contribution must provide tests for additional introduced conditions
|
||||
* Any un-confirmed issue needs a failing test case before being accepted
|
||||
* Pull requests must be sent from a new hotfix/feature branch, not from `master`.
|
||||
|
||||
## Installation
|
||||
|
||||
To install the project and run the tests, you need to clone it first:
|
||||
|
||||
```sh
|
||||
$ git clone git://github.com/Ocramius/PackageVersions.git
|
||||
```
|
||||
|
||||
You will then need to run a composer installation:
|
||||
|
||||
```sh
|
||||
$ cd PackageVersions
|
||||
$ curl -s https://getcomposer.org/installer | php
|
||||
$ php composer.phar update
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
The PHPUnit version to be used is the one installed as a dev- dependency via composer:
|
||||
|
||||
```sh
|
||||
$ ./vendor/bin/phpunit
|
||||
```
|
||||
|
||||
Accepted coverage for new contributions is 80%. Any contribution not satisfying this requirement
|
||||
won't be merged.
|
||||
|
||||
19
vendor/composer/package-versions-deprecated/LICENSE
vendored
Normal file
19
vendor/composer/package-versions-deprecated/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2016 Marco Pivetta
|
||||
|
||||
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.
|
||||
5
vendor/composer/package-versions-deprecated/README.md
vendored
Normal file
5
vendor/composer/package-versions-deprecated/README.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Package Versions
|
||||
|
||||
**`composer/package-versions-deprecated` is a fully-compatible fork of [`ocramius/package-versions`](https://github.com/Ocramius/PackageVersions)** which provides compatibility with Composer 1 and 2 on PHP 7+. It replaces ocramius/package-versions so if you have a dependency requiring it and you want to use Composer v2 but can not upgrade to PHP 7.4 just yet, you can require this package instead.
|
||||
|
||||
If you have a direct dependency on ocramius/package-versions, we recommend instead that once you migrated to Composer 2 you also migrate to use the `Composer\Versions` class which offers the functionality present here out of the box.
|
||||
5
vendor/composer/package-versions-deprecated/SECURITY.md
vendored
Normal file
5
vendor/composer/package-versions-deprecated/SECURITY.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
48
vendor/composer/package-versions-deprecated/composer.json
vendored
Normal file
48
vendor/composer/package-versions-deprecated/composer.json
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "composer/package-versions-deprecated",
|
||||
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
|
||||
"type": "composer-plugin",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marco Pivetta",
|
||||
"email": "ocramius@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jordi Boggiano",
|
||||
"email": "j.boggiano@seld.be"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7",
|
||||
"composer-plugin-api": "^1.1.0 || ^2.0"
|
||||
},
|
||||
"replace": {
|
||||
"ocramius/package-versions": "1.10.99"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.5 || ^7",
|
||||
"composer/composer": "^1.9.3 || ^2.0@dev",
|
||||
"ext-zip": "^1.13"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PackageVersions\\": "src/PackageVersions"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"PackageVersionsTest\\": "test/PackageVersionsTest"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"class": "PackageVersions\\Installer",
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-update-cmd": "PackageVersions\\Installer::dumpVersionsClass",
|
||||
"post-install-cmd": "PackageVersions\\Installer::dumpVersionsClass"
|
||||
}
|
||||
}
|
||||
2603
vendor/composer/package-versions-deprecated/composer.lock
generated
vendored
Normal file
2603
vendor/composer/package-versions-deprecated/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
vendor/composer/package-versions-deprecated/phpcs.xml.dist
vendored
Normal file
21
vendor/composer/package-versions-deprecated/phpcs.xml.dist
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset>
|
||||
<arg name="basepath" value="."/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="parallel" value="80"/>
|
||||
<arg name="cache" value=".phpcs-cache"/>
|
||||
<arg name="colors"/>
|
||||
|
||||
<arg value="nps"/>
|
||||
|
||||
<file>src</file>
|
||||
<file>test</file>
|
||||
|
||||
<rule ref="Doctrine">
|
||||
<exclude-pattern>src/PackageVersions/Versions.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="Generic.Strings.UnnecessaryStringConcat.Found">
|
||||
<exclude-pattern>src/PackageVersions/Installer.php</exclude-pattern>
|
||||
</rule>
|
||||
</ruleset>
|
||||
128
vendor/composer/package-versions-deprecated/src/PackageVersions/FallbackVersions.php
vendored
Normal file
128
vendor/composer/package-versions-deprecated/src/PackageVersions/FallbackVersions.php
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PackageVersions;
|
||||
|
||||
use Generator;
|
||||
use OutOfBoundsException;
|
||||
use UnexpectedValueException;
|
||||
use function array_key_exists;
|
||||
use function array_merge;
|
||||
use function basename;
|
||||
use function file_exists;
|
||||
use function file_get_contents;
|
||||
use function getcwd;
|
||||
use function iterator_to_array;
|
||||
use function json_decode;
|
||||
use function json_encode;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* This is a fallback for {@see \PackageVersions\Versions::getVersion()}
|
||||
* Do not use this class directly: it is intended to be only used when
|
||||
* {@see \PackageVersions\Versions} fails to be generated, which typically
|
||||
* happens when running composer with `--no-scripts` flag)
|
||||
*/
|
||||
final class FallbackVersions
|
||||
{
|
||||
const ROOT_PACKAGE_NAME = 'unknown/root-package@UNKNOWN';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws OutOfBoundsException If a version cannot be located.
|
||||
* @throws UnexpectedValueException If the composer.lock file could not be located.
|
||||
*/
|
||||
public static function getVersion(string $packageName): string
|
||||
{
|
||||
$versions = iterator_to_array(self::getVersions(self::getPackageData()));
|
||||
|
||||
if (! array_key_exists($packageName, $versions)) {
|
||||
throw new OutOfBoundsException(
|
||||
'Required package "' . $packageName . '" is not installed: check your ./vendor/composer/installed.json and/or ./composer.lock files'
|
||||
);
|
||||
}
|
||||
|
||||
return $versions[$packageName];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
private static function getPackageData(): array
|
||||
{
|
||||
$checkedPaths = [
|
||||
// The top-level project's ./vendor/composer/installed.json
|
||||
getcwd() . '/vendor/composer/installed.json',
|
||||
__DIR__ . '/../../../../composer/installed.json',
|
||||
// The top-level project's ./composer.lock
|
||||
getcwd() . '/composer.lock',
|
||||
__DIR__ . '/../../../../../composer.lock',
|
||||
// This package's composer.lock
|
||||
__DIR__ . '/../../composer.lock',
|
||||
];
|
||||
|
||||
$packageData = [];
|
||||
foreach ($checkedPaths as $path) {
|
||||
if (! file_exists($path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents($path), true);
|
||||
switch (basename($path)) {
|
||||
case 'installed.json':
|
||||
// composer 2.x installed.json format
|
||||
if (isset($data['packages'])) {
|
||||
$packageData[] = $data['packages'];
|
||||
} else {
|
||||
// composer 1.x installed.json format
|
||||
$packageData[] = $data;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'composer.lock':
|
||||
$packageData[] = $data['packages'] + ($data['packages-dev'] ?? []);
|
||||
break;
|
||||
default:
|
||||
// intentionally left blank
|
||||
}
|
||||
}
|
||||
|
||||
if ($packageData !== []) {
|
||||
return array_merge(...$packageData);
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException(sprintf(
|
||||
'PackageVersions could not locate the `vendor/composer/installed.json` or your `composer.lock` '
|
||||
. 'location. This is assumed to be in %s. If you customized your composer vendor directory and ran composer '
|
||||
. 'installation with --no-scripts, or if you deployed without the required composer files, PackageVersions '
|
||||
. 'can\'t detect installed versions.',
|
||||
json_encode($checkedPaths)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $packageData
|
||||
*
|
||||
* @return Generator&string[]
|
||||
*
|
||||
* @psalm-return Generator<string, string>
|
||||
*/
|
||||
private static function getVersions(array $packageData): Generator
|
||||
{
|
||||
foreach ($packageData as $package) {
|
||||
yield $package['name'] => $package['version'] . '@' . (
|
||||
$package['source']['reference'] ?? $package['dist']['reference'] ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
yield self::ROOT_PACKAGE_NAME => self::ROOT_PACKAGE_NAME;
|
||||
}
|
||||
}
|
||||
251
vendor/composer/package-versions-deprecated/src/PackageVersions/Installer.php
vendored
Normal file
251
vendor/composer/package-versions-deprecated/src/PackageVersions/Installer.php
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PackageVersions;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Config;
|
||||
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\Locker;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\RootPackageInterface;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
use Composer\Script\Event;
|
||||
use Composer\Script\ScriptEvents;
|
||||
use Generator;
|
||||
use RuntimeException;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_merge;
|
||||
use function chmod;
|
||||
use function dirname;
|
||||
use function file_exists;
|
||||
use function file_put_contents;
|
||||
use function is_writable;
|
||||
use function iterator_to_array;
|
||||
use function rename;
|
||||
use function sprintf;
|
||||
use function uniqid;
|
||||
use function var_export;
|
||||
|
||||
final class Installer implements PluginInterface, EventSubscriberInterface
|
||||
{
|
||||
private static $generatedClassTemplate = <<<'PHP'
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PackageVersions;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use OutOfBoundsException;
|
||||
|
||||
/**
|
||||
* This class is generated by composer/package-versions-deprecated, specifically by
|
||||
* @see \PackageVersions\Installer
|
||||
*
|
||||
* This file is overwritten at every run of `composer install` or `composer update`.
|
||||
*
|
||||
* @deprecated in favor of the Composer\InstalledVersions class provided by Composer 2. Require composer-runtime-api:^2 to ensure it is present.
|
||||
*/
|
||||
%s
|
||||
{
|
||||
/**
|
||||
* @deprecated please use {@see \Composer\InstalledVersions::getRootPackage()} instead. The
|
||||
* equivalent expression for this constant's contents is
|
||||
* `\Composer\InstalledVersions::getRootPackage()['name']`.
|
||||
* This constant will be removed in version 2.0.0.
|
||||
*/
|
||||
const ROOT_PACKAGE_NAME = '%s';
|
||||
|
||||
/**
|
||||
* Array of all available composer packages.
|
||||
* Dont read this array from your calling code, but use the \PackageVersions\Versions::getVersion() method instead.
|
||||
*
|
||||
* @var array<string, string>
|
||||
* @internal
|
||||
*/
|
||||
const VERSIONS = %s;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
class_exists(InstalledVersions::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws OutOfBoundsException If a version cannot be located.
|
||||
*
|
||||
* @psalm-param key-of<self::VERSIONS> $packageName
|
||||
* @psalm-pure
|
||||
*
|
||||
* @psalm-suppress ImpureMethodCall we know that {@see InstalledVersions} interaction does not
|
||||
* cause any side effects here.
|
||||
*/
|
||||
public static function getVersion(string $packageName): string
|
||||
{
|
||||
if (class_exists(InstalledVersions::class, false)) {
|
||||
return InstalledVersions::getPrettyVersion($packageName)
|
||||
. '@' . InstalledVersions::getReference($packageName);
|
||||
}
|
||||
|
||||
if (isset(self::VERSIONS[$packageName])) {
|
||||
return self::VERSIONS[$packageName];
|
||||
}
|
||||
|
||||
throw new OutOfBoundsException(
|
||||
'Required package "' . $packageName . '" is not installed: check your ./vendor/composer/installed.json and/or ./composer.lock files'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PHP;
|
||||
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
// Nothing to do here, as all features are provided through event listeners
|
||||
}
|
||||
|
||||
public function deactivate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
// Nothing to do here, as all features are provided through event listeners
|
||||
}
|
||||
|
||||
public function uninstall(Composer $composer, IOInterface $io)
|
||||
{
|
||||
// Nothing to do here, as all features are provided through event listeners
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [ScriptEvents::POST_AUTOLOAD_DUMP => 'dumpVersionsClass'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function dumpVersionsClass(Event $composerEvent)
|
||||
{
|
||||
$composer = $composerEvent->getComposer();
|
||||
$rootPackage = $composer->getPackage();
|
||||
$versions = iterator_to_array(self::getVersions($composer->getLocker(), $rootPackage));
|
||||
|
||||
if (! array_key_exists('composer/package-versions-deprecated', $versions)) {
|
||||
//plugin must be globally installed - we only want to generate versions for projects which specifically
|
||||
//require composer/package-versions-deprecated
|
||||
return;
|
||||
}
|
||||
|
||||
$versionClass = self::generateVersionsClass($rootPackage->getName(), $versions);
|
||||
|
||||
self::writeVersionClassToFile($versionClass, $composer, $composerEvent->getIO());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $versions
|
||||
*/
|
||||
private static function generateVersionsClass(string $rootPackageName, array $versions): string
|
||||
{
|
||||
return sprintf(
|
||||
self::$generatedClassTemplate,
|
||||
'fin' . 'al ' . 'cla' . 'ss ' . 'Versions', // note: workaround for regex-based code parsers :-(
|
||||
$rootPackageName,
|
||||
var_export($versions, true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private static function writeVersionClassToFile(string $versionClassSource, Composer $composer, IOInterface $io)
|
||||
{
|
||||
$installPath = self::locateRootPackageInstallPath($composer->getConfig(), $composer->getPackage())
|
||||
. '/src/PackageVersions/Versions.php';
|
||||
|
||||
$installDir = dirname($installPath);
|
||||
if (! file_exists($installDir)) {
|
||||
$io->write('<info>composer/package-versions-deprecated:</info> Package not found (probably scheduled for removal); generation of version class skipped.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! is_writable($installDir)) {
|
||||
$io->write(
|
||||
sprintf(
|
||||
'<info>composer/package-versions-deprecated:</info> %s is not writable; generation of version class skipped.',
|
||||
$installDir
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$io->write('<info>composer/package-versions-deprecated:</info> Generating version class...');
|
||||
|
||||
$installPathTmp = $installPath . '_' . uniqid('tmp', true);
|
||||
file_put_contents($installPathTmp, $versionClassSource);
|
||||
chmod($installPathTmp, 0664);
|
||||
rename($installPathTmp, $installPath);
|
||||
|
||||
$io->write('<info>composer/package-versions-deprecated:</info> ...done generating version class');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private static function locateRootPackageInstallPath(
|
||||
Config $composerConfig,
|
||||
RootPackageInterface $rootPackage
|
||||
): string {
|
||||
if (self::getRootPackageAlias($rootPackage)->getName() === 'composer/package-versions-deprecated') {
|
||||
return dirname($composerConfig->get('vendor-dir'));
|
||||
}
|
||||
|
||||
return $composerConfig->get('vendor-dir') . '/composer/package-versions-deprecated';
|
||||
}
|
||||
|
||||
private static function getRootPackageAlias(RootPackageInterface $rootPackage): PackageInterface
|
||||
{
|
||||
$package = $rootPackage;
|
||||
|
||||
while ($package instanceof AliasPackage) {
|
||||
$package = $package->getAliasOf();
|
||||
}
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generator&string[]
|
||||
*
|
||||
* @psalm-return Generator<string, string>
|
||||
*/
|
||||
private static function getVersions(Locker $locker, RootPackageInterface $rootPackage): Generator
|
||||
{
|
||||
$lockData = $locker->getLockData();
|
||||
|
||||
$lockData['packages-dev'] = $lockData['packages-dev'] ?? [];
|
||||
|
||||
foreach (array_merge($lockData['packages'], $lockData['packages-dev']) as $package) {
|
||||
yield $package['name'] => $package['version'] . '@' . (
|
||||
$package['source']['reference'] ?? $package['dist']['reference'] ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($rootPackage->getReplaces() as $replace) {
|
||||
$version = $replace->getPrettyConstraint();
|
||||
if ($version === 'self.version') {
|
||||
$version = $rootPackage->getPrettyVersion();
|
||||
}
|
||||
|
||||
yield $replace->getTarget() => $version . '@' . $rootPackage->getSourceReference();
|
||||
}
|
||||
|
||||
yield $rootPackage->getName() => $rootPackage->getPrettyVersion() . '@' . $rootPackage->getSourceReference();
|
||||
}
|
||||
}
|
||||
98
vendor/composer/package-versions-deprecated/src/PackageVersions/Versions.php
vendored
Normal file
98
vendor/composer/package-versions-deprecated/src/PackageVersions/Versions.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PackageVersions;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use OutOfBoundsException;
|
||||
|
||||
/**
|
||||
* This class is generated by composer/package-versions-deprecated, specifically by
|
||||
* @see \PackageVersions\Installer
|
||||
*
|
||||
* This file is overwritten at every run of `composer install` or `composer update`.
|
||||
*
|
||||
* @deprecated in favor of the Composer\InstalledVersions class provided by Composer 2. Require composer-runtime-api:^2 to ensure it is present.
|
||||
*/
|
||||
final class Versions
|
||||
{
|
||||
/**
|
||||
* @deprecated please use {@see \Composer\InstalledVersions::getRootPackage()} instead. The
|
||||
* equivalent expression for this constant's contents is
|
||||
* `\Composer\InstalledVersions::getRootPackage()['name']`.
|
||||
* This constant will be removed in version 2.0.0.
|
||||
*/
|
||||
const ROOT_PACKAGE_NAME = '__root__';
|
||||
|
||||
/**
|
||||
* Array of all available composer packages.
|
||||
* Dont read this array from your calling code, but use the \PackageVersions\Versions::getVersion() method instead.
|
||||
*
|
||||
* @var array<string, string>
|
||||
* @internal
|
||||
*/
|
||||
const VERSIONS = array (
|
||||
'clue/stream-filter' => 'v1.4.1@5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71',
|
||||
'composer/package-versions-deprecated' => '1.10.99@dd51b4443d58b34b6d9344cf4c288e621c9a826f',
|
||||
'guzzlehttp/guzzle' => '6.5.5@9d4290de1cfd701f38099ef7e183b64b4b7b0c5e',
|
||||
'guzzlehttp/promises' => 'v1.3.1@a59da6cf61d80060647ff4d3eb2c03a2bc694646',
|
||||
'guzzlehttp/psr7' => '1.6.1@239400de7a173fe9901b9ac7c06497751f00727a',
|
||||
'http-interop/http-factory-guzzle' => '1.0.0@34861658efb9899a6618cef03de46e2a52c80fc0',
|
||||
'jean85/pretty-package-versions' => '1.5.0@e9f4324e88b8664be386d90cf60fbc202e1f7fc9',
|
||||
'paragonie/random_compat' => 'v9.99.99@84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95',
|
||||
'php-http/client-common' => '2.3.0@e37e46c610c87519753135fb893111798c69076a',
|
||||
'php-http/discovery' => '1.9.1@64a18cc891957e05d91910b3c717d6bd11fbede9',
|
||||
'php-http/guzzle6-adapter' => 'v2.0.1@6074a4b1f4d5c21061b70bab3b8ad484282fe31f',
|
||||
'php-http/httplug' => '2.2.0@191a0a1b41ed026b717421931f8d3bd2514ffbf9',
|
||||
'php-http/message' => '1.8.0@ce8f43ac1e294b54aabf5808515c3554a19c1e1c',
|
||||
'php-http/message-factory' => 'v1.0.2@a478cb11f66a6ac48d8954216cfed9aa06a501a1',
|
||||
'php-http/promise' => '1.1.0@4c4c1f9b7289a2ec57cde7f1e9762a5789506f88',
|
||||
'psr/http-client' => '1.0.1@2dfb5f6c5eff0e91e20e913f8c5452ed95b86621',
|
||||
'psr/http-factory' => '1.0.1@12ac7fcd07e5b077433f5f2bee95b3a771bf61be',
|
||||
'psr/http-message' => '1.0.1@f6561bf28d520154e4b0ec72be95418abe6d9363',
|
||||
'psr/log' => '1.1.3@0f73288fd15629204f9d42b7055f72dacbe811fc',
|
||||
'ralouphie/getallheaders' => '3.0.3@120b605dfeb996808c31b6477290a714d356e822',
|
||||
'sentry/sdk' => '2.1.0@18921af9c2777517ef9fb480845c22a98554d6af',
|
||||
'sentry/sentry' => '2.4.2@b3b4f4a08b184c3f22b208f357e8720ef42938b0',
|
||||
'symfony/deprecation-contracts' => 'v2.1.3@5e20b83385a77593259c9f8beb2c43cd03b2ac14',
|
||||
'symfony/options-resolver' => 'v5.1.3@9ff59517938f88d90b6e65311fef08faa640f681',
|
||||
'symfony/polyfill-intl-idn' => 'v1.18.1@5dcab1bc7146cf8c1beaa4502a3d9be344334251',
|
||||
'symfony/polyfill-intl-normalizer' => 'v1.18.1@37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e',
|
||||
'symfony/polyfill-php70' => 'v1.18.1@0dd93f2c578bdc9c72697eaa5f1dd25644e618d3',
|
||||
'symfony/polyfill-php72' => 'v1.18.1@639447d008615574653fb3bc60d1986d7172eaae',
|
||||
'symfony/polyfill-php80' => 'v1.18.1@d87d5766cbf48d72388a9f6b85f280c8ad51f981',
|
||||
'symfony/polyfill-uuid' => 'v1.18.1@da48e2cccd323e48c16c26481bf5800f6ab1c49d',
|
||||
'__root__' => 'dev-issue-15@baeeca06cf3953f65f07b03106272a678e3eb15d',
|
||||
);
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
class_exists(InstalledVersions::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws OutOfBoundsException If a version cannot be located.
|
||||
*
|
||||
* @psalm-param key-of<self::VERSIONS> $packageName
|
||||
* @psalm-pure
|
||||
*
|
||||
* @psalm-suppress ImpureMethodCall we know that {@see InstalledVersions} interaction does not
|
||||
* cause any side effects here.
|
||||
*/
|
||||
public static function getVersion(string $packageName): string
|
||||
{
|
||||
if (class_exists(InstalledVersions::class, false)) {
|
||||
return InstalledVersions::getPrettyVersion($packageName)
|
||||
. '@' . InstalledVersions::getReference($packageName);
|
||||
}
|
||||
|
||||
if (isset(self::VERSIONS[$packageName])) {
|
||||
return self::VERSIONS[$packageName];
|
||||
}
|
||||
|
||||
throw new OutOfBoundsException(
|
||||
'Required package "' . $packageName . '" is not installed: check your ./vendor/composer/installed.json and/or ./composer.lock files'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user