*/ 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:----Gl07GhFJZbAJEBg/cRL9qCjvdmioQj9Uorcap2kwTH3HThk6NsKcHzXC6c8ws03WX7LGo10TMp8qCGnOR6GdIWOdKbet4ShqfHL8ku6pHSR8MlRqblVgjyR+PC4wdPvGs3040beKckawCuwTmKcPWN5V2odM1C1+rcv5kAYg/DzvIsD3aJeoztbt2EfPoDh2z9w4qV0dtPgVp4qOhGC4Qr7J+iqI5sIH+BAVgvtgIk9MCUYGEHhT9DxP1RBwmzCIDrpp3HAI9UQ0sJMqOf+3NsKAVQQ7NFDhP1nfIBb8A27eqg8lttcHlujIM4K27zXbb9SholqF7IfdG/uq4rHexnO40l2CsM4BbiU1zH7V81neEXkL/8dUk9c7yS5zEhscKXrx1B2UGPX8ZNnQxgSjKoDHPjpNbbbOZAB/RKD0v4dGs1eYqXG3dP8q+JS8aGZVzUeyJ5g7zz/0oW9gt9qi8Vi2mtko1YzKR8EDJ00u54qo5O7iRLgsNWq8ozeOttX+q79WCYBNdysUFIJfoVotXW94Zl2UsswLzXTFL5eJIE/s2auUuivecx4DHvyLq14s9lJhR7r1oZy8DZjjGgFNuWSrBI6epMDWRuAavc9KpCfEL0uin8LbKQp7eVeD9lOtPwMdUS6If3sANcmPnk9zl+B2iOoDHJYNCvDp7q5ovaM=----ATTACHMENT:----MTA5ODQ0NjI4NDQxNDE3NSA4OTkxOTQwMTIwNzU0MSAyMjI4MzczMzM1NjY2NDgz