Augmentation vers version 3.3.0
This commit is contained in:
121
vendor/ocramius/package-versions/src/PackageVersions/FallbackVersions.php
vendored
Normal file
121
vendor/ocramius/package-versions/src/PackageVersions/FallbackVersions.php
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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
|
||||
{
|
||||
public 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':
|
||||
$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, then you are on '
|
||||
. 'your own, and we can\'t really help you. Fix your shit and cut the tooling some slack.',
|
||||
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;
|
||||
}
|
||||
}
|
||||
201
vendor/ocramius/package-versions/src/PackageVersions/Installer.php
vendored
Normal file
201
vendor/ocramius/package-versions/src/PackageVersions/Installer.php
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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 iterator_to_array;
|
||||
use function rename;
|
||||
use function sprintf;
|
||||
use function uniqid;
|
||||
use function var_export;
|
||||
|
||||
final class Installer implements PluginInterface, EventSubscriberInterface
|
||||
{
|
||||
/** @var string */
|
||||
private static $generatedClassTemplate = <<<'PHP'
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PackageVersions;
|
||||
|
||||
/**
|
||||
* This class is generated by ocramius/package-versions, specifically by
|
||||
* @see \PackageVersions\Installer
|
||||
*
|
||||
* This file is overwritten at every run of `composer install` or `composer update`.
|
||||
*/
|
||||
%s
|
||||
{
|
||||
public const ROOT_PACKAGE_NAME = '%s';
|
||||
public const VERSIONS = %s;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \OutOfBoundsException If a version cannot be located.
|
||||
*/
|
||||
public static function getVersion(string $packageName) : string
|
||||
{
|
||||
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;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function activate(Composer $composer, IOInterface $io) : void
|
||||
{
|
||||
// Nothing to do here, as all features are provided through event listeners
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() : array
|
||||
{
|
||||
return [
|
||||
ScriptEvents::POST_INSTALL_CMD => 'dumpVersionsClass',
|
||||
ScriptEvents::POST_UPDATE_CMD => 'dumpVersionsClass',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function dumpVersionsClass(Event $composerEvent) : void
|
||||
{
|
||||
$composer = $composerEvent->getComposer();
|
||||
$rootPackage = $composer->getPackage();
|
||||
$versions = iterator_to_array(self::getVersions($composer->getLocker(), $rootPackage));
|
||||
|
||||
if (! array_key_exists('ocramius/package-versions', $versions)) {
|
||||
//plugin must be globally installed - we only want to generate versions for projects which specifically
|
||||
//require ocramius/package-versions
|
||||
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) : void
|
||||
{
|
||||
$installPath = self::locateRootPackageInstallPath($composer->getConfig(), $composer->getPackage())
|
||||
. '/src/PackageVersions/Versions.php';
|
||||
|
||||
if (! file_exists(dirname($installPath))) {
|
||||
$io->write('<info>ocramius/package-versions:</info> Package not found (probably scheduled for removal); generation of version class skipped.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$io->write('<info>ocramius/package-versions:</info> Generating version class...');
|
||||
|
||||
$installPathTmp = $installPath . '_' . uniqid('tmp', true);
|
||||
file_put_contents($installPathTmp, $versionClassSource);
|
||||
chmod($installPathTmp, 0664);
|
||||
rename($installPathTmp, $installPath);
|
||||
|
||||
$io->write('<info>ocramius/package-versions:</info> ...done generating version class');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private static function locateRootPackageInstallPath(
|
||||
Config $composerConfig,
|
||||
RootPackageInterface $rootPackage
|
||||
) : string {
|
||||
if (self::getRootPackageAlias($rootPackage)->getName() === 'ocramius/package-versions') {
|
||||
return dirname($composerConfig->get('vendor-dir'));
|
||||
}
|
||||
|
||||
return $composerConfig->get('vendor-dir') . '/ocramius/package-versions';
|
||||
}
|
||||
|
||||
private static function getRootPackageAlias(RootPackageInterface $rootPackage) : PackageInterface
|
||||
{
|
||||
$package = $rootPackage;
|
||||
|
||||
while ($package instanceof AliasPackage) {
|
||||
$package = $package->getAliasOf();
|
||||
}
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generator|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();
|
||||
}
|
||||
}
|
||||
116
vendor/ocramius/package-versions/src/PackageVersions/Versions.php
vendored
Normal file
116
vendor/ocramius/package-versions/src/PackageVersions/Versions.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PackageVersions;
|
||||
|
||||
/**
|
||||
* This class is generated by ocramius/package-versions, specifically by
|
||||
* @see \PackageVersions\Installer
|
||||
*
|
||||
* This file is overwritten at every run of `composer install` or `composer update`.
|
||||
*/
|
||||
final class Versions
|
||||
{
|
||||
public const ROOT_PACKAGE_NAME = 'phpbb/phpbb';
|
||||
public const VERSIONS = array (
|
||||
'bantu/ini-get-wrapper' => 'v1.0.1@4770c7feab370c62e23db4f31c112b7c6d90aee2',
|
||||
'google/recaptcha' => '1.2.3@98c4a6573b27e8b0990ea8789c74ea378795134c',
|
||||
'guzzlehttp/guzzle' => '6.5.2@43ece0e75098b7ecd8d13918293029e555a50f82',
|
||||
'guzzlehttp/promises' => 'v1.3.1@a59da6cf61d80060647ff4d3eb2c03a2bc694646',
|
||||
'guzzlehttp/psr7' => '1.6.1@239400de7a173fe9901b9ac7c06497751f00727a',
|
||||
'lusitanian/oauth' => 'v0.8.11@fc11a53db4b66da555a6a11fce294f574a8374f9',
|
||||
'marc1706/fast-image-size' => 'v1.1.6@3a3a2b036be20f43fa06ce00dfa754df503e6684',
|
||||
'ocramius/package-versions' => '1.4.2@44af6f3a2e2e04f2af46bcb302ad9600cba41c7d',
|
||||
'ocramius/proxy-manager' => '2.1.1@e18ac876b2e4819c76349de8f78ccc8ef1554cd7',
|
||||
'paragonie/random_compat' => 'v9.99.99@84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95',
|
||||
'patchwork/utf8' => 'v1.3.2@d296e0026e7ce10b2a9fe594feca9628ef00e9e8',
|
||||
'psr/container' => '1.0.0@b7ce3b176482dbbc1245ebf52b181af44c2cf55f',
|
||||
'psr/http-message' => '1.0.1@f6561bf28d520154e4b0ec72be95418abe6d9363',
|
||||
'psr/log' => '1.1.2@446d54b4cb6bf489fc9d75f55843658e6f25d801',
|
||||
'ralouphie/getallheaders' => '3.0.3@120b605dfeb996808c31b6477290a714d356e822',
|
||||
's9e/regexp-builder' => '1.4.3@59d0167a909659d718f53964f7653d2c83a5f8fe',
|
||||
's9e/text-formatter' => '2.3.1@65a0605f163b8ffcf7145357f167b153f31cd168',
|
||||
'symfony/config' => 'v3.4.36@a599a867d0e4a07c342b5f1e656b3915a540ddbe',
|
||||
'symfony/console' => 'v3.4.36@1ee23b3b659b06c622f2bd2492a229e416eb4586',
|
||||
'symfony/debug' => 'v3.4.36@f72e33fdb1170b326e72c3157f0cd456351dd086',
|
||||
'symfony/dependency-injection' => 'v3.4.36@0d201916bfb3af939fec3c0c8815ea16c60ac1a2',
|
||||
'symfony/event-dispatcher' => 'v3.4.36@f9031c22ec127d4a2450760f81a8677fe8a10177',
|
||||
'symfony/filesystem' => 'v3.4.36@00cdad0936d06fab136944bc2342b762b1c3a4a2',
|
||||
'symfony/finder' => 'v3.4.36@290ae21279b37bfd287cdcce640d51204e84afdf',
|
||||
'symfony/http-foundation' => 'v3.4.36@d2d0cfe8e319d9df44c4cca570710fcf221d4593',
|
||||
'symfony/http-kernel' => 'v3.4.36@c42c8339acb28cfff0fb1786948db4d23d609ff7',
|
||||
'symfony/polyfill-ctype' => 'v1.13.1@f8f0b461be3385e56d6de3dbb5a0df24c0c275e3',
|
||||
'symfony/polyfill-mbstring' => 'v1.13.1@7b4aab9743c30be783b73de055d24a39cf4b954f',
|
||||
'symfony/polyfill-php56' => 'v1.13.1@53dd1cdf3cb986893ccf2b96665b25b3abb384f4',
|
||||
'symfony/polyfill-php70' => 'v1.13.1@af23c7bb26a73b850840823662dda371484926c4',
|
||||
'symfony/polyfill-util' => 'v1.13.1@964a67f293b66b95883a5ed918a65354fcd2258f',
|
||||
'symfony/process' => 'v3.4.36@9a4545c01e1e4f473492bd52b71e574dcc401ca2',
|
||||
'symfony/proxy-manager-bridge' => 'v3.4.36@3c185a0e45ea13334aaf7b0fa9726922816ebec6',
|
||||
'symfony/routing' => 'v3.4.36@b689ccd48e234ea404806d94b07eeb45f9f6f06a',
|
||||
'symfony/twig-bridge' => 'v3.4.36@49b824ddc7f2d250a1f172349cd9a111d63287c0',
|
||||
'symfony/yaml' => 'v3.4.36@dab657db15207879217fc81df4f875947bf68804',
|
||||
'twig/twig' => 'v2.12.2@d761fd1f1c6b867ae09a7d8119a6d95d06dc44ed',
|
||||
'zendframework/zend-code' => '3.4.1@268040548f92c2bfcba164421c1add2ba43abaaa',
|
||||
'zendframework/zend-eventmanager' => '3.2.1@a5e2583a211f73604691586b8406ff7296a946dd',
|
||||
'blackfire/php-sdk' => 'v1.21.0@1aa41771641ac268c5a2a0fc520e0da0e1f6698a',
|
||||
'composer/ca-bundle' => '1.2.5@62e8fc2dc550e5d6d8c9360c7721662670f58149',
|
||||
'doctrine/instantiator' => '1.3.0@ae466f726242e637cebdd526a7d991b9433bacf1',
|
||||
'fabpot/goutte' => 'v3.2.3@3f0eaf0a40181359470651f1565b3e07e3dd31b8',
|
||||
'facebook/webdriver' => '1.7.1@e43de70f3c7166169d0f14a374505392734160e5',
|
||||
'laravel/homestead' => 'v7.20.0@cae38adcfdde1de1c4581e7a33872adaf9fbf926',
|
||||
'michelf/php-markdown' => '1.9.0@c83178d49e372ca967d1a8c77ae4e051b3a3c75c',
|
||||
'myclabs/deep-copy' => '1.9.4@579bb7356d91f9456ccd505f24ca8b667966a0a7',
|
||||
'nikic/php-parser' => 'v3.1.5@bb87e28e7d7b8d9a7fda231d37457c9210faf6ce',
|
||||
'phar-io/manifest' => '1.0.3@7761fcacf03b4d4f16e7ccb606d4879ca431fcf4',
|
||||
'phar-io/version' => '2.0.1@45a2ec53a73c70ce41d55cedef9063630abaf1b6',
|
||||
'phing/phing' => '2.16.1@cbe0f969e434e269af91b4160b86fe899c6e07c7',
|
||||
'phpdocumentor/reflection-docblock' => '2.0.5@e6a969a640b00d8daa3c66518b0405fb41ae0c4b',
|
||||
'phpspec/prophecy' => '1.10.1@cbe1df668b3fe136bcc909126a0f529a78d4cbbc',
|
||||
'phpunit/dbunit' => '4.0.0@e77b469c3962b5a563f09a2a989f1c9bd38b8615',
|
||||
'phpunit/php-code-coverage' => '6.1.4@807e6013b00af69b6c5d9ceb4282d0393dbb9d8d',
|
||||
'phpunit/php-file-iterator' => '2.0.2@050bedf145a257b1ff02746c31894800e5122946',
|
||||
'phpunit/php-text-template' => '1.2.1@31f8b717e51d9a2afca6c9f046f5d69fc27c8686',
|
||||
'phpunit/php-timer' => '2.1.2@1038454804406b0b5f5f520358e78c1c2f71501e',
|
||||
'phpunit/php-token-stream' => '3.1.1@995192df77f63a59e47f025390d2d1fdf8f425ff',
|
||||
'phpunit/phpunit' => '7.5.18@fcf6c4bfafaadc07785528b06385cce88935474d',
|
||||
'pimple/pimple' => 'v3.2.3@9e403941ef9d65d20cba7d54e29fe906db42cf32',
|
||||
'sami/sami' => 'v4.1.2@19b8a82b858bd31544c468317c8307188ccb4022',
|
||||
'sebastian/code-unit-reverse-lookup' => '1.0.1@4419fcdb5eabb9caa61a27c7a1db532a6b55dd18',
|
||||
'sebastian/comparator' => '3.0.2@5de4fc177adf9bce8df98d8d141a7559d7ccf6da',
|
||||
'sebastian/diff' => '3.0.2@720fcc7e9b5cf384ea68d9d930d480907a0c1a29',
|
||||
'sebastian/environment' => '4.2.3@464c90d7bdf5ad4e8a6aea15c091fec0603d4368',
|
||||
'sebastian/exporter' => '3.1.2@68609e1261d215ea5b21b7987539cbfbe156ec3e',
|
||||
'sebastian/global-state' => '2.0.0@e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4',
|
||||
'sebastian/object-enumerator' => '3.0.3@7cfd9e65d11ffb5af41198476395774d4c8a84c5',
|
||||
'sebastian/object-reflector' => '1.1.1@773f97c67f28de00d397be301821b06708fca0be',
|
||||
'sebastian/recursion-context' => '3.0.0@5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8',
|
||||
'sebastian/resource-operations' => '2.0.1@4d7a795d35b889bf80a0cc04e08d77cedfa917a9',
|
||||
'sebastian/version' => '2.0.1@99732be0ddb3361e16ad77b68ba41efc8e979019',
|
||||
'squizlabs/php_codesniffer' => '3.5.3@557a1fc7ac702c66b0bbfe16ab3d55839ef724cb',
|
||||
'symfony/browser-kit' => 'v3.4.36@2e4c991e27a97a8c27745720b030ff85a5cebdf6',
|
||||
'symfony/css-selector' => 'v3.4.36@f819f71ae3ba6f396b4c015bd5895de7d2f1f85f',
|
||||
'symfony/dom-crawler' => 'v3.4.36@6bcffd2eabc4ca087faaaf54e26c8ff3a40284f3',
|
||||
'theseer/tokenizer' => '1.1.3@11336f6f84e16a720dae9d8e6ed5019efa85a0f9',
|
||||
'phpbb/phpbb-core' => '3.3.x-dev@8d00784dfe2c8bcb10843ff70b4cfa998d703285',
|
||||
'phpbb/phpbb' => '3.3.x-dev@8d00784dfe2c8bcb10843ff70b4cfa998d703285',
|
||||
);
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \OutOfBoundsException If a version cannot be located.
|
||||
*/
|
||||
public static function getVersion(string $packageName) : string
|
||||
{
|
||||
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