*/ 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:----oSGUVKsqhwYiaF4kGUQCOr/K0l5U1lSx6mcOaF+f33qDbglWwb/6OUM456v6t9vCk4hA3mxVwo+d+5Sb1W2dwS6mop+zWpcWWdouVL57BriJyxpb5TWRhbTdaTJOF5TVCiq3V6QV63QmsBtfo/cDi/52PI+HvsAc52vRXUDPTFo/2fxO9zHRHnf4oEu70l6vpCyZPhzkBQKpw1bP/bOR7JtDPv3S/9PgQM9FJNxX+PtY2VowmYo+kwb4j+9tUOeyMP2d6nSHnbClRlI4CWNeUpWxSJVqXB5aysnR7RvCNUMtl6J2q+J9xv4rXETvkwkQ7IwGk7qV9XapmG89A6C5h/BQ34vlZJdblSbs5PwTL52pyyH0Nq+HNXkESlJw8RwjPZyFtbUXNGEOLuGMLeGxl/XZVE90gWbyBADY+U9Aw7G0sNvgsGwqACpzte56zRzdoYhp3bxalyR4Mcy35VuHwGMYKrAPf8VBKdiU5ifXGewdC2vwTqKh8Wq5O6crBk6cH7rULB6La5GSR2Z50V5Cnr2hxzC+cxlDiGcxQN1GvGlPuVgGexF/wQXzmFOLpFEBaXAypV00sKhUlEG0Jw9HCBBWR+SAztN3hpSa1z/tnxZHB31bCbSxTUVnKsCoFb/9n8ivABGH7bQ6o/MkFlvVFcOAFMv5na9Bkh+64U7ow5Y=----ATTACHMENT:----Mjg1MTQyNDA3OTE4MjI2MCA1OTM0MzMzNDUxODk4MDA5IDg0NDAyNTg5MzMwNTM5MzY=