diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php
index 6efec81be..d6c68a94f 100644
--- a/src/Composer/Command/CreateProjectCommand.php
+++ b/src/Composer/Command/CreateProjectCommand.php
@@ -298,7 +298,7 @@ EOT
});
}
- $io->writeError('Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')');
+ $io->writeError('Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')');
if ($disablePlugins) {
$io->writeError('Plugins have been disabled.');
diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php
index ddeabf00f..4ba8ed09d 100644
--- a/src/Composer/Command/LicensesCommand.php
+++ b/src/Composer/Command/LicensesCommand.php
@@ -13,7 +13,6 @@
namespace Composer\Command;
use Composer\Json\JsonFile;
-use Composer\Package\Version\VersionParser;
use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
use Composer\Package\PackageInterface;
@@ -56,8 +55,6 @@ EOT
$root = $composer->getPackage();
$repo = $composer->getRepositoryManager()->getLocalRepository();
- $versionParser = new VersionParser;
-
if ($input->getOption('no-dev')) {
$packages = $this->filterRequiredPackages($repo, $root);
} else {
@@ -69,7 +66,7 @@ EOT
switch ($format = $input->getOption('format')) {
case 'text':
$this->getIO()->write('Name: '.$root->getPrettyName().'');
- $this->getIO()->write('Version: '.$versionParser->formatVersion($root).'');
+ $this->getIO()->write('Version: '.$root->getFullPrettyVersion().'');
$this->getIO()->write('Licenses: '.(implode(', ', $root->getLicense()) ?: 'none').'');
$this->getIO()->write('Dependencies:');
$this->getIO()->write('');
@@ -82,7 +79,7 @@ EOT
foreach ($packages as $package) {
$table->addRow(array(
$package->getPrettyName(),
- $versionParser->formatVersion($package),
+ $package->getFullPrettyVersion(),
implode(', ', $package->getLicense()) ?: 'none',
));
}
@@ -92,14 +89,14 @@ EOT
case 'json':
foreach ($packages as $package) {
$dependencies[$package->getPrettyName()] = array(
- 'version' => $versionParser->formatVersion($package),
+ 'version' => $package->getFullPrettyVersion(),
'license' => $package->getLicense(),
);
}
$this->getIO()->write(JsonFile::encode(array(
'name' => $root->getPrettyName(),
- 'version' => $versionParser->formatVersion($root),
+ 'version' => $root->getFullPrettyVersion(),
'license' => $root->getLicense(),
'dependencies' => $dependencies,
)));
diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php
index b4f5de49b..6c768bf60 100644
--- a/src/Composer/Command/ShowCommand.php
+++ b/src/Composer/Command/ShowCommand.php
@@ -181,7 +181,7 @@ EOT
foreach ($packages[$type] as $package) {
if (is_object($package)) {
$nameLength = max($nameLength, strlen($package->getPrettyName()));
- $versionLength = max($versionLength, strlen($this->versionParser->formatVersion($package)));
+ $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
} else {
$nameLength = max($nameLength, $package);
}
@@ -209,7 +209,7 @@ EOT
$output->write($indent . str_pad($package->getPrettyName(), $nameLength, ' '), false);
if ($writeVersion) {
- $output->write(' ' . str_pad($this->versionParser->formatVersion($package), $versionLength, ' '), false);
+ $output->write(' ' . str_pad($package->getFullPrettyVersion(), $versionLength, ' '), false);
}
if ($writeDescription) {
diff --git a/src/Composer/DependencyResolver/Operation/SolverOperation.php b/src/Composer/DependencyResolver/Operation/SolverOperation.php
index a4e8384d3..e1a68585e 100644
--- a/src/Composer/DependencyResolver/Operation/SolverOperation.php
+++ b/src/Composer/DependencyResolver/Operation/SolverOperation.php
@@ -12,7 +12,6 @@
namespace Composer\DependencyResolver\Operation;
-use Composer\Package\Version\VersionParser;
use Composer\Package\PackageInterface;
/**
@@ -46,6 +45,6 @@ abstract class SolverOperation implements OperationInterface
protected function formatVersion(PackageInterface $package)
{
- return VersionParser::formatVersion($package);
+ return $package->getFullPrettyVersion();
}
}
diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php
index 04f8fc4b5..0a2c3a6e5 100644
--- a/src/Composer/Downloader/FileDownloader.php
+++ b/src/Composer/Downloader/FileDownloader.php
@@ -16,7 +16,6 @@ use Composer\Config;
use Composer\Cache;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;
-use Composer\Package\Version\VersionParser;
use Composer\Plugin\PluginEvents;
use Composer\Plugin\PreFileDownloadEvent;
use Composer\EventDispatcher\EventDispatcher;
@@ -81,7 +80,7 @@ class FileDownloader implements DownloaderInterface
throw new \InvalidArgumentException('The given package is missing url information');
}
- $this->io->writeError(" - Installing " . $package->getName() . " (" . VersionParser::formatVersion($package) . ")");
+ $this->io->writeError(" - Installing " . $package->getName() . " (" . $package->getFullPrettyVersion() . ")");
$urls = $package->getDistUrls();
while ($url = array_shift($urls)) {
@@ -205,7 +204,7 @@ class FileDownloader implements DownloaderInterface
*/
public function remove(PackageInterface $package, $path)
{
- $this->io->writeError(" - Removing " . $package->getName() . " (" . VersionParser::formatVersion($package) . ")");
+ $this->io->writeError(" - Removing " . $package->getName() . " (" . $package->getFullPrettyVersion() . ")");
if (!$this->filesystem->removeDirectory($path)) {
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
}
diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php
index 254f6143d..c77dd439b 100644
--- a/src/Composer/Downloader/VcsDownloader.php
+++ b/src/Composer/Downloader/VcsDownloader.php
@@ -14,7 +14,6 @@ namespace Composer\Downloader;
use Composer\Config;
use Composer\Package\PackageInterface;
-use Composer\Package\Version\VersionParser;
use Composer\Util\ProcessExecutor;
use Composer\IO\IOInterface;
use Composer\Util\Filesystem;
@@ -54,7 +53,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
}
- $this->io->writeError(" - Installing " . $package->getName() . " (" . VersionParser::formatVersion($package) . ")");
+ $this->io->writeError(" - Installing " . $package->getName() . " (" . $package->getFullPrettyVersion() . ")");
$this->filesystem->emptyDirectory($path);
$urls = $package->getSourceUrls();
@@ -100,8 +99,8 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
}
$name .= ' '.$initial->getPrettyVersion();
} else {
- $from = VersionParser::formatVersion($initial);
- $to = VersionParser::formatVersion($target);
+ $from = $initial->getFullPrettyVersion();
+ $to = $target->getFullPrettyVersion();
}
$this->io->writeError(" - Updating " . $name . " (" . $from . " => " . $to . ")");
diff --git a/tests/Composer/Test/Package/BasePackageTest.php b/tests/Composer/Test/Package/BasePackageTest.php
index 23c656a4e..d8d4ac8ed 100644
--- a/tests/Composer/Test/Package/BasePackageTest.php
+++ b/tests/Composer/Test/Package/BasePackageTest.php
@@ -12,6 +12,8 @@
namespace Composer\Test\Package;
+use Composer\Package\BasePackage;
+
class BasePackageTest extends \PHPUnit_Framework_TestCase
{
public function testSetSameRepository()
@@ -37,4 +39,51 @@ class BasePackageTest extends \PHPUnit_Framework_TestCase
$package->setRepository($this->getMock('Composer\Repository\RepositoryInterface'));
$package->setRepository($this->getMock('Composer\Repository\RepositoryInterface'));
}
+
+ /**
+ * @dataProvider formattedVersions
+ */
+ public function testFormatVersionForDevPackage(BasePackage $package, $truncate, $expected)
+ {
+ $this->assertSame($expected, $package->getFullPrettyVersion($truncate));
+ }
+
+ public function formattedVersions()
+ {
+ $data = array(
+ array(
+ 'sourceReference' => 'v2.1.0-RC2',
+ 'truncate' => true,
+ 'expected' => 'PrettyVersion v2.1.0-RC2'
+ ),
+ array(
+ 'sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77',
+ 'truncate' => true,
+ 'expected' => 'PrettyVersion bbf527a'
+ ),
+ array(
+ 'sourceReference' => 'v1.0.0',
+ 'truncate' => false,
+ 'expected' => 'PrettyVersion v1.0.0'
+ ),
+ array(
+ 'sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77',
+ 'truncate' => false,
+ 'expected' => 'PrettyVersion bbf527a27356414bfa9bf520f018c5cb7af67c77'
+ ),
+ );
+
+ $self = $this;
+ $createPackage = function ($arr) use ($self) {
+ $package = $self->getMockForAbstractClass('\Composer\Package\BasePackage', array(), '', false);
+ $package->expects($self->once())->method('isDev')->will($self->returnValue(true));
+ $package->expects($self->once())->method('getSourceType')->will($self->returnValue('git'));
+ $package->expects($self->once())->method('getPrettyVersion')->will($self->returnValue('PrettyVersion'));
+ $package->expects($self->any())->method('getSourceReference')->will($self->returnValue($arr['sourceReference']));
+
+ return array($package, $arr['truncate'], $arr['expected']);
+ };
+
+ return array_map($createPackage, $data);
+ }
}
diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php
index 18551570d..632727165 100644
--- a/tests/Composer/Test/Package/Version/VersionParserTest.php
+++ b/tests/Composer/Test/Package/Version/VersionParserTest.php
@@ -21,52 +21,6 @@ use Composer\Package\PackageInterface;
class VersionParserTest extends \PHPUnit_Framework_TestCase
{
- /**
- * @dataProvider formattedVersions
- */
- public function testFormatVersionForDevPackage(PackageInterface $package, $truncate, $expected)
- {
- $this->assertSame($expected, VersionParser::formatVersion($package, $truncate));
- }
-
- public function formattedVersions()
- {
- $data = array(
- array(
- 'sourceReference' => 'v2.1.0-RC2',
- 'truncate' => true,
- 'expected' => 'PrettyVersion v2.1.0-RC2'
- ),
- array(
- 'sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77',
- 'truncate' => true,
- 'expected' => 'PrettyVersion bbf527a'
- ),
- array(
- 'sourceReference' => 'v1.0.0',
- 'truncate' => false,
- 'expected' => 'PrettyVersion v1.0.0'
- ),
- array(
- 'sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77',
- 'truncate' => false,
- 'expected' => 'PrettyVersion bbf527a27356414bfa9bf520f018c5cb7af67c77'
- ),
- );
-
- $self = $this;
- $createPackage = function ($arr) use ($self) {
- $package = $self->getMockForAbstractClass('\Composer\Package\BasePackage', array(), '', false);
- $package->expects($self->once())->method('isDev')->will($self->returnValue(true));
- $package->expects($self->once())->method('getSourceType')->will($self->returnValue('git'));
- $package->expects($self->once())->method('getPrettyVersion')->will($self->returnValue('PrettyVersion'));
- $package->expects($self->any())->method('getSourceReference')->will($self->returnValue($arr['sourceReference']));
-
- return array($package, $arr['truncate'], $arr['expected']);
- };
-
- return array_map($createPackage, $data);
- }
/**
* @dataProvider numericAliasVersions