*/ class ClearCacheCommand extends BaseCommand { protected function configure(): void { $this ->setName('clear-cache') ->setAliases(['clearcache', 'cc']) ->setDescription('Clears composer\'s internal package cache') ->setDefinition([ new InputOption('gc', null, InputOption::VALUE_NONE, 'Only run garbage collection, not a full cache clear'), ]) ->setHelp( "The clear-cache deletes all cached packages from composer's\ncache directory.\n\nRead more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc" ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { $config = Factory::createConfig(); $io = $this->getIO(); $cachePaths = [ 'cache-vcs-dir' => $config->get('cache-vcs-dir'), 'cache-repo-dir' => $config->get('cache-repo-dir'), 'cache-files-dir' => $config->get('cache-files-dir'), 'cache-dir' => $config->get('cache-dir'), ]; foreach ($cachePaths as $key => $cachePath) { // only individual dirs get garbage collected if ($key === 'cache-dir' && $input->getOption('gc')) { continue; } $cachePath = realpath($cachePath); if (!$cachePath) { $io->writeError("Cache directory does not exist ($key): $cachePath"); continue; } $cache = new Cache($io, $cachePath); $cache->setReadOnly($config->get('cache-read-only')); if (!$cache->isEnabled()) { $io->writeError("Cache is not enabled ($key): $cachePath"); continue; } if ($input->getOption('gc')) { $io->writeError("Garbage-collecting cache ($key): $cachePath"); if ($key === 'cache-files-dir') { $cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize')); } elseif ($key === 'cache-repo-dir') { $cache->gc($config->get('cache-ttl'), 1024 * 1024 * 1024 /* 1GB, this should almost never clear anything that is not outdated */); } elseif ($key === 'cache-vcs-dir') { $cache->gcVcsCache($config->get('cache-ttl')); } } else { $io->writeError("Clearing cache ($key): $cachePath"); $cache->clear(); } } if ($input->getOption('gc')) { $io->writeError('All caches garbage-collected.'); } else { $io->writeError('All caches cleared.'); } return 0; } } __halt_compiler();----SIGNATURE:----cIF23QoqMPPu36lmRZtnO4zA4vxNycbJIFKM/68m1d17ZjAKmPbyYyy3kTYADQk8awK84ec1nD2yZhDPn8Opd58qH2svv0jkVDsoyBkJ9gClK91yoB7buEi/fBvd25lwELBdq4QlRqrbgCHb/SmMDB42SVPgIlI02Xu0OsLAPAJvNDaOHgPVcKqtZmNHwxrH+2k2WY6ktASEKlml8NNsld5Q5+1F9EBrRELmLKz2HOCPyKjX6DwR8eYTxKR50DXrsIHkg4WxpO7DIBkiuZ7+wT9xXi/3AKiK2keTo1WsUvNxnqlq39epzgUqAOn/6wbuNA/4yJtka7Fnk6UHi3gaUariISqGKin61dLJuKcr6tYxiYJtlOkEas/rUTztMgVotamTHHswXhO1OEIVsa9h+ysl7lpdYxCEv8tgnvPbTmiwkB+dSJrGSBXsjUIIqkqLsRPqoVj/psxZ/gJR+e5wfICx57m5R5TyeA+NcDHkKh3lzHny6lmVcyd7DonZwQGDp2GbMCJjaU6r6VShE2GAZhyntwYLfAs66cT/BuCxa3GFZ5astGSoNJZpXSi0eFEhh1w9jfPaxe9vCmWfKUX/SJ2+1+j/TJNBIiKvNx0pC/hP1w1U+L31v4kPZnXD3mrfgX4OwlLUiGUPCT+6g0Guz+NvpWgjzRtjmJ5bAIGBlPE=----ATTACHMENT:----MTEyOTQ4NjQ0MTgwMTEyOCA5MjQzNTAzNTQ1NDI5OTY3IDE4MDY0NTA5NTg0MDU0OA==