public function execute() { foreach ($this->repository->getUnusedPhars() as $unusedPhar) { $this->repository->removePhar($unusedPhar); $this->output->writeInfo(sprintf('Phar %s %s has been deleted.', $unusedPhar->getName(), $unusedPhar->getVersion()->getVersionString())); } }
/** * @expectedException \PharIo\Phive\DownloadFailedException */ public function testThrowsExceptionIfKeyWasNotFound() { $response = $this->prophesize(CurlResponse::class); $response->getHttpCode()->willReturn(404); $response->getErrorMessage()->willReturn('Not Found'); $this->curl->get(Argument::any(), Argument::any())->willReturn($response); $downloader = new GnupgKeyDownloader($this->curl->reveal(), [new Url('https://example.com')], $this->output->reveal()); $downloader->download('12345678'); }
/** * @param string $error * @param string $file * @param int $line * @param array|null $trace */ private function showError($error, $file, $line, array $trace = null) { $baseLen = strlen(realpath(__DIR__ . '/../../..')) + 1; $message = [$error]; $message[] = ''; $message[] = sprintf('#0 %s(%d)', substr($file, $baseLen), $line); if ($trace != null) { foreach ($trace as $pos => $step) { $file = 'unknown file'; if (isset($step['file'])) { $file = substr($step['file'], $baseLen); } $message[] = sprintf('#%d %s(%d): %s%s%s()', $pos + 1, $file, isset($step['line']) ? $step['line'] : 0, isset($step['class']) ? $step['class'] : '', isset($step['type']) ? $step['type'] : '', $step['function']); } $message[] = sprintf('#%d {main}', count($trace) + 1); } $this->ouput->writeError(sprintf(file_get_contents(__DIR__ . '/error.txt'), join("\n ", $message), $this->environment->getRuntimeString(), $this->version->getVersion())); }
public function execute() { $this->output->writeText($this->version->getVersionString() . "\n\n"); }
/** * @return KeyService */ private function getKeyService() { return new KeyService($this->downloader->reveal(), $this->importer->reveal(), $this->output->reveal(), $this->input->reveal()); }
/** * @return PharService */ private function getPharService() { return new PharService($this->downloader->reveal(), $this->installer->reveal(), $this->repository->reveal(), $this->resolver->reveal(), $this->output->reveal(), $this->pharIoRepositoryFactory->reveal()); }
public function execute() { $this->output->writeText($this->version->getVersionString() . "\n\n"); $this->output->writeText(str_replace('%phive', $this->environment->getBinaryName(), file_get_contents(__DIR__ . '/help.txt')) . "\n\n"); }