관리-도구
편집 파일: InstalledVersions.php
<?php namespace Composer; use Composer\Semver\VersionParser; class InstalledVersions { private static $installed = array ( 'root' => array ( 'pretty_version' => 'dev-release/4.8', 'version' => 'dev-release/4.8', 'aliases' => array ( ), 'reference' => 'c9a204b0c11d252a56c90ffd1fa947d5cadbb7b1', 'name' => 'kkart/kkart', ), 'versions' => array ( 'automattic/jetpack-autoloader' => array ( 'pretty_version' => 'v2.2.0', 'version' => '2.2.0.0', 'aliases' => array ( ), 'reference' => '66a5d150b3928be718d86696f85631a7f0b98a7b', ), 'automattic/jetpack-constants' => array ( 'pretty_version' => 'v1.5.0', 'version' => '1.5.0.0', 'aliases' => array ( ), 'reference' => '9827a2f446b8c4faafaf1c740483031c073a381d', ), 'composer/installers' => array ( 'pretty_version' => 'v1.9.0', 'version' => '1.9.0.0', 'aliases' => array ( ), 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', ), 'league/container' => array ( 'pretty_version' => '3.3.3', 'version' => '3.3.3.0', 'aliases' => array ( ), 'reference' => '7dc67bdf89efc338e674863c0ea70a63efe4de05', ), 'maxmind-db/reader' => array ( 'pretty_version' => 'v1.6.0', 'version' => '1.6.0.0', 'aliases' => array ( ), 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', ), 'orno/di' => array ( 'replaced' => array ( 0 => '~2.0', ), ), 'pelago/emogrifier' => array ( 'pretty_version' => 'v3.1.0', 'version' => '3.1.0.0', 'aliases' => array ( ), 'reference' => 'f6a5c7d44612d86c3901c93f1592f5440e6b2cd8', ), 'psr/container' => array ( 'pretty_version' => '1.0.0', 'version' => '1.0.0.0', 'aliases' => array ( ), 'reference' => 'b7ce3b176482dbbc1245ebf52b181af44c2cf55f', ), 'psr/container-implementation' => array ( 'provided' => array ( 0 => '^1.0', ), ), 'roundcube/plugin-installer' => array ( 'replaced' => array ( 0 => '*', ), ), 'shama/baton' => array ( 'replaced' => array ( 0 => '*', ), ), 'symfony/css-selector' => array ( 'pretty_version' => 'v3.3.6', 'version' => '3.3.6.0', 'aliases' => array ( ), 'reference' => '4d882dced7b995d5274293039370148e291808f2', ), 'kkart/action-scheduler' => array ( 'pretty_version' => '3.1.6', 'version' => '3.1.6.0', 'aliases' => array ( ), 'reference' => '275d0ba54b1c263dfc62688de2fa9a25a373edf8', ), 'kkart/kkart' => array ( 'pretty_version' => 'dev-release/4.8', 'version' => 'dev-release/4.8', 'aliases' => array ( ), 'reference' => 'c9a204b0c11d252a56c90ffd1fa947d5cadbb7b1', ), 'kkart/kkart-admin' => array ( 'pretty_version' => '1.7.3', 'version' => '1.7.3.0', 'aliases' => array ( ), 'reference' => '16de972f319e5e6fc8dbebf5024dd263234f39e0', ), 'kkart/kkart-blocks' => array ( 'pretty_version' => 'v3.8.1', 'version' => '3.8.1.0', 'aliases' => array ( ), 'reference' => 'e5aef9eddd13c5511ba673eb70ed8cb3e80d828c', ), ), ); public static function getInstalledPackages() { return array_keys(self::$installed['versions']); } public static function isInstalled($packageName) { return isset(self::$installed['versions'][$packageName]); } public static function satisfies(VersionParser $parser, $packageName, $constraint) { $constraint = $parser->parseConstraints($constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); } public static function getVersionRanges($packageName) { if (!isset(self::$installed['versions'][$packageName])) { throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } $ranges = array(); if (isset(self::$installed['versions'][$packageName]['pretty_version'])) { $ranges[] = self::$installed['versions'][$packageName]['pretty_version']; } if (array_key_exists('aliases', self::$installed['versions'][$packageName])) { $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']); } if (array_key_exists('replaced', self::$installed['versions'][$packageName])) { $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']); } if (array_key_exists('provided', self::$installed['versions'][$packageName])) { $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']); } return implode(' || ', $ranges); } public static function getVersion($packageName) { if (!isset(self::$installed['versions'][$packageName])) { throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } if (!isset(self::$installed['versions'][$packageName]['version'])) { return null; } return self::$installed['versions'][$packageName]['version']; } public static function getPrettyVersion($packageName) { if (!isset(self::$installed['versions'][$packageName])) { throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) { return null; } return self::$installed['versions'][$packageName]['pretty_version']; } public static function getReference($packageName) { if (!isset(self::$installed['versions'][$packageName])) { throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } if (!isset(self::$installed['versions'][$packageName]['reference'])) { return null; } return self::$installed['versions'][$packageName]['reference']; } public static function getRootPackage() { return self::$installed['root']; } public static function getRawData() { return self::$installed; } public static function reload($data) { self::$installed = $data; } }