*/ class Versions { public const CHANNELS = ['stable', 'preview', 'snapshot', '1', '2', '2.2']; /** * @var string[] * @deprecated use Versions::CHANNELS */ public static $channels = self::CHANNELS; /** @var HttpDownloader */ private $httpDownloader; /** @var Config */ private $config; /** @var string */ private $channel; /** @var array>|null */ private $versionsData = null; public function __construct(Config $config, HttpDownloader $httpDownloader) { $this->httpDownloader = $httpDownloader; $this->config = $config; } public function getChannel(): string { if ($this->channel) { return $this->channel; } $channelFile = $this->config->get('home').'/update-channel'; if (file_exists($channelFile)) { $channel = trim(file_get_contents($channelFile)); if (in_array($channel, ['stable', 'preview', 'snapshot', '2.2'], true)) { return $this->channel = $channel; } } return $this->channel = 'stable'; } public function setChannel(string $channel, ?IOInterface $io = null): void { if (!in_array($channel, self::$channels, true)) { throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels)); } $channelFile = $this->config->get('home').'/update-channel'; $this->channel = $channel; // rewrite '2' and '1' channels to stable for future self-updates, but LTS ones like '2.2' remain pinned $storedChannel = Preg::isMatch('{^\d+$}D', $channel) ? 'stable' : $channel; $previouslyStored = file_exists($channelFile) ? trim((string) file_get_contents($channelFile)) : null; file_put_contents($channelFile, $storedChannel.PHP_EOL); if ($io !== null && $previouslyStored !== $storedChannel) { $io->writeError('Storing "'.$storedChannel.'" as default update channel for the next self-update run.'); } } /** * @return array{path: string, version: string, min-php: int, eol?: true} */ public function getLatest(?string $channel = null): array { $versions = $this->getVersionsData(); foreach ($versions[$channel ?: $this->getChannel()] as $version) { if ($version['min-php'] <= PHP_VERSION_ID) { return $version; } } throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')'); } /** * @return array> */ private function getVersionsData(): array { if (null === $this->versionsData) { if ($this->config->get('disable-tls') === true) { $protocol = 'http'; } else { $protocol = 'https'; } $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson(); } return $this->versionsData; } } __halt_compiler();----SIGNATURE:----mwWzhJBROmeTuOWYkPQwEJyzYavvgiXuOgZiM4Hbfg7Xk4/IC/qJS83frjWxTN9dOgLlMvX2DM1MNdPDkCoBIdL4E4iRlZGY35pIE2EcwY3+zAvLeeL1ILC1evDmQZNvfuxESk+elmzKiIJXLu7fkz/EGeQcu+43kTci8V/DCWFdHQpL1gWklzVn7DauLm1o1SQIT7Z5fz762rXRcrt/10oxdOmrpX3V96dWxqgkmjIa9NSy4Z6wZBBdX87J8KW6rg3Q+Oge7axrmYFImn6r9JoKK7S9nmKmpBWJ9/zAhtjsPsF5p+oBB+VNMr0boUQJtaW7endFVVn16WJWHKp1iLenl2QyxgAvp+S5VxVre0bHY7G3awU3o5Fl/ZXnPb2UQdMO+7hzsz3b4XAFS5RIbZBSMMMF6AZmqbj9/KwoV7u1zVWUCe1ZqGTfBQM0he3ZO27HW0ThvG/2z3GL2fxxJrYZrPvXb7O4IWjxYHO+AbaPmoG6KFD5i95UlzDy0Fuzy5tl/ufuGXnn4aWGm0OMUgy0qNU311Y1psgP9G1O4W8GgGbr1l851w3E9O7BDsMzS9o5jKCMFDMrB9+cl+8MYpE0SIo7nBKKAaQtFLwKhlz4vP2f+wQgojEZ+Xr9LMVoCeorPFPlXFBV5Twbj9pBX1eaIXqgDNB7Y2C4pLKSJ0I=----ATTACHMENT:----NjM0NzY1MDc3Mzc4NzMxNyA5MzgxMDA4MzA5NjgwODcyIDgzODQzOTA0MzM0NDExNDA=