diff options
Diffstat (limited to 'vendor/composer/InstalledVersions.php')
-rw-r--r-- | vendor/composer/InstalledVersions.php | 127 |
1 files changed, 31 insertions, 96 deletions
diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index e597e0eb3..49f5297d5 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -12,7 +12,6 @@ namespace Composer; -use Composer\Autoload\ClassLoader; use Composer\Semver\VersionParser; @@ -25,12 +24,12 @@ class InstalledVersions private static $installed = array ( 'root' => array ( - 'pretty_version' => 'dev-5.2RC', - 'version' => 'dev-5.2RC', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', 'aliases' => array ( ), - 'reference' => 'a6162d3134cd7fcde4f45064b75f90008a7f8177', + 'reference' => '1bcf84f27510e9afe20a3c6a509ca7062aba0aa9', 'name' => 'zotlabs/hubzilla', ), 'versions' => @@ -267,17 +266,15 @@ private static $installed = array ( ), 'zotlabs/hubzilla' => array ( - 'pretty_version' => 'dev-5.2RC', - 'version' => 'dev-5.2RC', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', 'aliases' => array ( ), - 'reference' => 'a6162d3134cd7fcde4f45064b75f90008a7f8177', + 'reference' => '1bcf84f27510e9afe20a3c6a509ca7062aba0aa9', ), ), ); -private static $canGetVendors; -private static $installedByVendor = array(); @@ -287,17 +284,7 @@ private static $installedByVendor = array(); public static function getInstalledPackages() { -$packages = array(); -foreach (self::getInstalled() as $installed) { -$packages[] = array_keys($installed['versions']); -} - - -if (1 === \count($packages)) { -return $packages[0]; -} - -return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); +return array_keys(self::$installed['versions']); } @@ -310,13 +297,7 @@ return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); public static function isInstalled($packageName) { -foreach (self::getInstalled() as $installed) { -if (isset($installed['versions'][$packageName])) { -return true; -} -} - -return false; +return isset(self::$installed['versions'][$packageName]); } @@ -351,50 +332,42 @@ return $provided->matches($constraint); public static function getVersionRanges($packageName) { -foreach (self::getInstalled() as $installed) { -if (!isset($installed['versions'][$packageName])) { -continue; +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } $ranges = array(); -if (isset($installed['versions'][$packageName]['pretty_version'])) { -$ranges[] = $installed['versions'][$packageName]['pretty_version']; +if (isset(self::$installed['versions'][$packageName]['pretty_version'])) { +$ranges[] = self::$installed['versions'][$packageName]['pretty_version']; } -if (array_key_exists('aliases', $installed['versions'][$packageName])) { -$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); +if (array_key_exists('aliases', self::$installed['versions'][$packageName])) { +$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']); } -if (array_key_exists('replaced', $installed['versions'][$packageName])) { -$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); +if (array_key_exists('replaced', self::$installed['versions'][$packageName])) { +$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']); } -if (array_key_exists('provided', $installed['versions'][$packageName])) { -$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); +if (array_key_exists('provided', self::$installed['versions'][$packageName])) { +$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']); } return implode(' || ', $ranges); } -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - public static function getVersion($packageName) { -foreach (self::getInstalled() as $installed) { -if (!isset($installed['versions'][$packageName])) { -continue; +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } -if (!isset($installed['versions'][$packageName]['version'])) { +if (!isset(self::$installed['versions'][$packageName]['version'])) { return null; } -return $installed['versions'][$packageName]['version']; -} - -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +return self::$installed['versions'][$packageName]['version']; } @@ -403,19 +376,15 @@ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed public static function getPrettyVersion($packageName) { -foreach (self::getInstalled() as $installed) { -if (!isset($installed['versions'][$packageName])) { -continue; +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } -if (!isset($installed['versions'][$packageName]['pretty_version'])) { +if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) { return null; } -return $installed['versions'][$packageName]['pretty_version']; -} - -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +return self::$installed['versions'][$packageName]['pretty_version']; } @@ -424,19 +393,15 @@ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed public static function getReference($packageName) { -foreach (self::getInstalled() as $installed) { -if (!isset($installed['versions'][$packageName])) { -continue; +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } -if (!isset($installed['versions'][$packageName]['reference'])) { +if (!isset(self::$installed['versions'][$packageName]['reference'])) { return null; } -return $installed['versions'][$packageName]['reference']; -} - -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +return self::$installed['versions'][$packageName]['reference']; } @@ -445,9 +410,7 @@ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed public static function getRootPackage() { -$installed = self::getInstalled(); - -return $installed[0]['root']; +return self::$installed['root']; } @@ -482,33 +445,5 @@ return self::$installed; public static function reload($data) { self::$installed = $data; -self::$installedByVendor = array(); -} - - - - -private static function getInstalled() -{ -if (null === self::$canGetVendors) { -self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); -} - -$installed = array(); - -if (self::$canGetVendors) { - -foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { -if (isset(self::$installedByVendor[$vendorDir])) { -$installed[] = self::$installedByVendor[$vendorDir]; -} elseif (is_file($vendorDir.'/composer/installed.php')) { -$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; -} -} -} - -$installed[] = self::$installed; - -return $installed; } } |