本文整理汇总了PHP中Composer\Package\PackageInterface::getFullPrettyVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP PackageInterface::getFullPrettyVersion方法的具体用法?PHP PackageInterface::getFullPrettyVersion怎么用?PHP PackageInterface::getFullPrettyVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\PackageInterface
的用法示例。
在下文中一共展示了PackageInterface::getFullPrettyVersion方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
/**
* {@inheritdoc}
*/
public function download(PackageInterface $package, $path)
{
$url = $package->getDistUrl();
$realUrl = realpath($url);
if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
throw new \RuntimeException(sprintf('Source path "%s" is not found for package %s', $url, $package->getName()));
}
if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
throw new \RuntimeException(sprintf('Package %s cannot install to "%s" inside its source at "%s"', $package->getName(), realpath($path), $realUrl));
}
$fileSystem = new Filesystem();
$this->filesystem->removeDirectory($path);
$this->io->writeError(sprintf(' - Installing <info>%s</info> (<comment>%s</comment>)', $package->getName(), $package->getFullPrettyVersion()));
try {
if (Platform::isWindows()) {
// Implement symlinks as NTFS junctions on Windows
$this->filesystem->junction($realUrl, $path);
$this->io->writeError(sprintf(' Junctioned from %s', $url));
} else {
$shortestPath = $this->filesystem->findShortestPath($path, $realUrl);
$fileSystem->symlink($shortestPath, $path);
$this->io->writeError(sprintf(' Symlinked from %s', $url));
}
} catch (IOException $e) {
$fileSystem->mirror($realUrl, $path);
$this->io->writeError(sprintf(' Mirrored from %s', $url));
}
$this->io->writeError('');
}
示例2: update
/**
* {@inheritDoc}
*/
public function update(PackageInterface $initial, PackageInterface $target, $path)
{
if (!$target->getSourceReference()) {
throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
}
$name = $target->getName();
if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
$from = $initial->getSourceReference();
$to = $target->getSourceReference();
$name .= ' ' . $initial->getPrettyVersion();
} else {
$from = $initial->getFullPrettyVersion();
$to = $target->getFullPrettyVersion();
}
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
$urls = $target->getSourceUrls();
while ($url = array_shift($urls)) {
try {
if (Filesystem::isLocalPath($url)) {
$url = realpath($url);
}
$this->doUpdate($initial, $target, $path, $url);
break;
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getMessage());
} elseif (count($urls)) {
$this->io->writeError(' Failed, trying the next URL');
} else {
throw $e;
}
}
}
$this->io->writeError('');
}
示例3: download
/**
* {@inheritdoc}
*/
public function download(PackageInterface $package, $path)
{
$fileSystem = new Filesystem();
$this->filesystem->removeDirectory($path);
$this->io->writeError(sprintf(' - Installing <info>%s</info> (<comment>%s</comment>) from %s', $package->getName(), $package->getFullPrettyVersion(), $package->getDistUrl()));
try {
$fileSystem->symlink($package->getDistUrl(), $path);
} catch (IOException $e) {
$fileSystem->mirror($package->getDistUrl(), $path);
}
}
示例4: download
public function download(PackageInterface $package, $path)
{
$temporaryDir = $this->config->get('vendor-dir') . '/composer/' . substr(md5(uniqid('', true)), 0, 8);
$this->filesystem->ensureDirectoryExists($temporaryDir);
// START: from FileDownloader::download()
if (!$package->getDistUrl()) {
throw new \InvalidArgumentException('The given package is missing url information');
}
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
$urls = $package->getDistUrls();
while ($url = array_shift($urls)) {
try {
$fileName = $this->doDownload($package, $temporaryDir, $url);
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('');
$this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getCode() . ': ' . $e->getMessage());
} elseif (count($urls)) {
$this->io->writeError('');
$this->io->writeError(' Failed, trying the next URL (' . $e->getCode() . ': ' . $e->getMessage() . ')');
}
if (!count($urls)) {
throw $e;
}
}
}
// END: from FileDownloader::download()
if ($this->io->isVerbose()) {
$this->io->writeError(' Extracting archive');
}
try {
$this->extract($fileName, $path);
} catch (\Exception $e) {
// remove cache if the file was corrupted
parent::clearCache($package, $path);
throw $e;
}
$this->filesystem->unlink($fileName);
if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir') . '/composer/')) {
$this->filesystem->removeDirectory($this->config->get('vendor-dir') . '/composer/');
}
if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir'))) {
$this->filesystem->removeDirectory($this->config->get('vendor-dir'));
}
$this->io->writeError('');
}
示例5: download
/**
* {@inheritdoc}
*/
public function download(PackageInterface $package, $path)
{
$fileSystem = new Filesystem();
$this->filesystem->removeDirectory($path);
$this->io->writeError(sprintf(' - Installing <info>%s</info> (<comment>%s</comment>)', $package->getName(), $package->getFullPrettyVersion()));
$url = $package->getDistUrl();
$realUrl = realpath($url);
if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
throw new \RuntimeException(sprintf('Path "%s" is not found', $url));
}
try {
$fileSystem->symlink($realUrl, $path);
$this->io->writeError(sprintf(' Symlinked from %s', $url));
} catch (IOException $e) {
$fileSystem->mirror($realUrl, $path);
$this->io->writeError(sprintf(' Mirrored from %s', $url));
}
$this->io->writeError('');
}
示例6: formatVersion
/**
* @deprecated Use PackageInterface::getFullPrettyVersion instead
*/
public static function formatVersion(PackageInterface $package, $truncate = true)
{
trigger_error(__METHOD__ . ' is deprecated. Use ' . '\\Composer\\Package\\PackageInterface::getFullPrettyVersion() instead', E_USER_DEPRECATED);
return $package->getFullPrettyVersion($truncate);
}
示例7: update
/**
* {@inheritDoc}
*/
public function update(PackageInterface $initial, PackageInterface $target, $path)
{
if (!$target->getSourceReference()) {
throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
}
$name = $target->getName();
if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
if ($target->getSourceType() === 'svn') {
$from = $initial->getSourceReference();
$to = $target->getSourceReference();
} else {
$from = substr($initial->getSourceReference(), 0, 7);
$to = substr($target->getSourceReference(), 0, 7);
}
$name .= ' ' . $initial->getPrettyVersion();
} else {
$from = $initial->getFullPrettyVersion();
$to = $target->getFullPrettyVersion();
}
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
$this->cleanChanges($initial, $path, true);
$urls = $target->getSourceUrls();
$exception = null;
while ($url = array_shift($urls)) {
try {
if (Filesystem::isLocalPath($url)) {
$url = realpath($url);
}
$this->doUpdate($initial, $target, $path, $url);
$exception = null;
break;
} catch (\Exception $exception) {
// rethrow phpunit exceptions to avoid hard to debug bug failures
if ($exception instanceof \PHPUnit_Framework_Exception) {
throw $exception;
}
if ($this->io->isDebug()) {
$this->io->writeError('Failed: [' . get_class($exception) . '] ' . $exception->getMessage());
} elseif (count($urls)) {
$this->io->writeError(' Failed, trying the next URL');
}
}
}
$this->reapplyChanges($path);
// print the commit logs if in verbose mode and VCS metadata is present
// because in case of missing metadata code would trigger another exception
if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
$message = 'Pulling in changes:';
$logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
if (!trim($logs)) {
$message = 'Rolling back changes:';
$logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
}
if (trim($logs)) {
$logs = implode("\n", array_map(function ($line) {
return ' ' . $line;
}, explode("\n", $logs)));
// escape angle brackets for proper output in the console
$logs = str_replace('<', '\\<', $logs);
$this->io->writeError(' ' . $message);
$this->io->writeError($logs);
}
}
if (!$urls && $exception) {
throw $exception;
}
$this->io->writeError('');
}
示例8: getVersionStyle
protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
{
if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
// print green as it's up to date
return 'info';
}
$constraint = $package->getVersion();
if (0 !== strpos($constraint, 'dev-')) {
$constraint = '^' . $constraint;
}
if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
// print red as it needs an immediate semver-compliant upgrade
return 'highlight';
}
// print yellow as it needs an upgrade but has potential BC breaks so is not urgent
return 'comment';
}
示例9: getFullPrettyVersion
/**
* {@inheritDoc}
*/
public function getFullPrettyVersion($truncate = true)
{
return $this->package->getFullPrettyVersion($truncate);
}
示例10: remove
/**
* {@inheritDoc}
*/
public function remove(PackageInterface $package, $path)
{
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
if (!$this->filesystem->removeDirectory($path)) {
throw new \RuntimeException('Could not completely delete ' . $path . ', aborting.');
}
}
示例11: update
/**
* {@inheritDoc}
*/
public function update(PackageInterface $initial, PackageInterface $target, $path)
{
if (!$target->getSourceReference()) {
throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
}
$name = $target->getName();
if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
if ($target->getSourceType() === 'svn') {
$from = $initial->getSourceReference();
$to = $target->getSourceReference();
} else {
$from = substr($initial->getSourceReference(), 0, 7);
$to = substr($target->getSourceReference(), 0, 7);
}
$name .= ' ' . $initial->getPrettyVersion();
} else {
$from = $initial->getFullPrettyVersion();
$to = $target->getFullPrettyVersion();
}
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
$this->cleanChanges($initial, $path, true);
$urls = $target->getSourceUrls();
while ($url = array_shift($urls)) {
try {
if (Filesystem::isLocalPath($url)) {
$url = realpath($url);
}
$this->doUpdate($initial, $target, $path, $url);
break;
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getMessage());
} elseif (count($urls)) {
$this->io->writeError(' Failed, trying the next URL');
} else {
// in case of failed update, try to reapply the changes before aborting
$this->reapplyChanges($path);
throw $e;
}
}
}
$this->reapplyChanges($path);
// print the commit logs if in verbose mode
if ($this->io->isVerbose()) {
$message = 'Pulling in changes:';
$logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
if (!trim($logs)) {
$message = 'Rolling back changes:';
$logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
}
if (trim($logs)) {
$logs = implode("\n", array_map(function ($line) {
return ' ' . $line;
}, explode("\n", $logs)));
// escape angle brackets for proper output in the console
$logs = str_replace('<', '\\<', $logs);
$this->io->writeError(' ' . $message);
$this->io->writeError($logs);
}
}
$this->io->writeError('');
}
示例12: remove
/**
* {@inheritDoc}
*/
public function remove(PackageInterface $package, $path)
{
/**
* For junctions don't blindly rely on Filesystem::removeDirectory as it may be overzealous. If a process
* inadvertently locks the file the removal will fail, but it would fall back to recursive delete which
* is disastrous within a junction. So in that case we have no other real choice but to fail hard.
*/
if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
$this->io->writeError(" - Removing junction for <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
if (!$this->filesystem->removeJunction($path)) {
$this->io->writeError("<warn>Could not remove junction at " . $path . " - is another process locking it?</warn>");
throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
}
} else {
parent::remove($package, $path);
}
}
示例13: formatVersion
protected function formatVersion(PackageInterface $package)
{
return $package->getFullPrettyVersion();
}