-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27331 from nextcloud/debt/noid/add-mbstring-depen…
…dency Add mbstring dependency
- Loading branch information
Showing
5 changed files
with
330 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,299 @@ | ||
<?php | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
namespace Composer; | ||
|
||
use Composer\Autoload\ClassLoader; | ||
use Composer\Semver\VersionParser; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
class InstalledVersions | ||
{ | ||
private static $installed = array ( | ||
'root' => | ||
array ( | ||
'pretty_version' => 'dev-master', | ||
'version' => 'dev-master', | ||
'aliases' => | ||
array ( | ||
), | ||
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07', | ||
'name' => '__root__', | ||
), | ||
'versions' => | ||
array ( | ||
'__root__' => | ||
array ( | ||
'pretty_version' => 'dev-master', | ||
'version' => 'dev-master', | ||
'aliases' => | ||
array ( | ||
), | ||
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07', | ||
), | ||
), | ||
); | ||
private static $canGetVendors; | ||
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))); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public static function isInstalled($packageName) | ||
{ | ||
foreach (self::getInstalled() as $installed) { | ||
if (isset($installed['versions'][$packageName])) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
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) | ||
{ | ||
foreach (self::getInstalled() as $installed) { | ||
if (!isset($installed['versions'][$packageName])) { | ||
continue; | ||
} | ||
|
||
$ranges = array(); | ||
if (isset($installed['versions'][$packageName]['pretty_version'])) { | ||
$ranges[] = $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('replaced', $installed['versions'][$packageName])) { | ||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); | ||
} | ||
if (array_key_exists('provided', $installed['versions'][$packageName])) { | ||
$ranges = array_merge($ranges, $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($installed['versions'][$packageName]['version'])) { | ||
return null; | ||
} | ||
|
||
return $installed['versions'][$packageName]['version']; | ||
} | ||
|
||
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($installed['versions'][$packageName]['pretty_version'])) { | ||
return null; | ||
} | ||
|
||
return $installed['versions'][$packageName]['pretty_version']; | ||
} | ||
|
||
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($installed['versions'][$packageName]['reference'])) { | ||
return null; | ||
} | ||
|
||
return $installed['versions'][$packageName]['reference']; | ||
} | ||
|
||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
public static function getRootPackage() | ||
{ | ||
$installed = self::getInstalled(); | ||
|
||
return $installed[0]['root']; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public static function getRawData() | ||
{ | ||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); | ||
|
||
return self::$installed; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public static function getAllRawData() | ||
{ | ||
return self::getInstalled(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php return array ( | ||
'root' => | ||
array ( | ||
'pretty_version' => 'dev-master', | ||
'version' => 'dev-master', | ||
'aliases' => | ||
array ( | ||
), | ||
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07', | ||
'name' => '__root__', | ||
), | ||
'versions' => | ||
array ( | ||
'__root__' => | ||
array ( | ||
'pretty_version' => 'dev-master', | ||
'version' => 'dev-master', | ||
'aliases' => | ||
array ( | ||
), | ||
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07', | ||
), | ||
), | ||
); |