[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare(strict_types=1); 4 5 namespace PackageVersions; 6 7 use Composer\InstalledVersions; 8 use OutOfBoundsException; 9 use UnexpectedValueException; 10 11 class_exists(InstalledVersions::class); 12 13 /** 14 * This is a stub class: it is in place only for scenarios where PackageVersions 15 * is installed with a `--no-scripts` flag, in which scenarios the Versions class 16 * is not being replaced. 17 * 18 * If you are reading this docBlock inside your `vendor/` dir, then this means 19 * that PackageVersions didn't correctly install, and is in "fallback" mode. 20 * 21 * @deprecated in favor of the Composer\InstalledVersions class provided by Composer 2. Require composer-runtime-api:^2 to ensure it is present. 22 */ 23 final class Versions 24 { 25 /** 26 * @deprecated please use {@see self::rootPackageName()} instead. 27 * This constant will be removed in version 2.0.0. 28 */ 29 const ROOT_PACKAGE_NAME = 'unknown/root-package@UNKNOWN'; 30 31 /** @internal */ 32 const VERSIONS = []; 33 34 private function __construct() 35 { 36 } 37 38 /** 39 * @psalm-pure 40 * 41 * @psalm-suppress ImpureMethodCall we know that {@see InstalledVersions} interaction does not 42 * cause any side effects here. 43 */ 44 public static function rootPackageName() : string 45 { 46 if (!class_exists(InstalledVersions::class, false) || !InstalledVersions::getRawData()) { 47 return self::ROOT_PACKAGE_NAME; 48 } 49 50 return InstalledVersions::getRootPackage()['name']; 51 } 52 53 /** 54 * @throws OutOfBoundsException if a version cannot be located. 55 * @throws UnexpectedValueException if the composer.lock file could not be located. 56 */ 57 public static function getVersion(string $packageName): string 58 { 59 if (!self::composer2ApiUsable()) { 60 return FallbackVersions::getVersion($packageName); 61 } 62 63 /** @psalm-suppress DeprecatedConstant */ 64 if ($packageName === self::ROOT_PACKAGE_NAME) { 65 $rootPackage = InstalledVersions::getRootPackage(); 66 67 return $rootPackage['pretty_version'] . '@' . $rootPackage['reference']; 68 } 69 70 return InstalledVersions::getPrettyVersion($packageName) 71 . '@' . InstalledVersions::getReference($packageName); 72 } 73 74 private static function composer2ApiUsable(): bool 75 { 76 if (!class_exists(InstalledVersions::class, false)) { 77 return false; 78 } 79 80 if (method_exists(InstalledVersions::class, 'getAllRawData')) { 81 $rawData = InstalledVersions::getAllRawData(); 82 if (count($rawData) === 1 && count($rawData[0]) === 0) { 83 return false; 84 } 85 } else { 86 $rawData = InstalledVersions::getRawData(); 87 if ($rawData === null || $rawData === []) { 88 return false; 89 } 90 } 91 92 return true; 93 } 94 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |