diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index f0dba7567..f0d3d379c 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -17,6 +17,7 @@ use Composer\Package\AliasPackage; use Composer\Repository\RepositorySet; use Composer\Repository\LockArrayRepository; use Composer\Semver\Constraint\Constraint; +use Composer\Package\Version\VersionParser; /** * Represents a problem detected while solving dependencies @@ -295,8 +296,8 @@ class Problem } foreach ($prepared as $name => $package) { // remove the implicit dev-master alias to avoid cruft in the display - if (isset($package['versions']['9999999-dev']) && isset($package['versions']['dev-master'])) { - unset($package['versions']['9999999-dev']); + if (isset($package['versions'][VersionParser::DEV_MASTER_ALIAS]) && isset($package['versions']['dev-master'])) { + unset($package['versions'][VersionParser::DEV_MASTER_ALIAS]); } $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']'; } diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index 7514cecce..2e82dab82 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -17,6 +17,7 @@ use Composer\Package\Link; use Composer\Package\PackageInterface; use Composer\Package\AliasPackage; use Composer\Repository\RepositorySet; +use Composer\Package\Version\VersionParser; /** * @author Nils Adermann @@ -283,7 +284,7 @@ abstract class Rule private function deduplicateMasterAlias(PackageInterface $package) { - if ($package instanceof AliasPackage && $package->getPrettyVersion() === '9999999-dev') { + if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEV_MASTER_ALIAS) { $package = $package->getAliasOf(); } diff --git a/src/Composer/Package/AliasPackage.php b/src/Composer/Package/AliasPackage.php index 3e117f7d9..6f380d7d2 100644 --- a/src/Composer/Package/AliasPackage.php +++ b/src/Composer/Package/AliasPackage.php @@ -173,9 +173,9 @@ class AliasPackage extends BasePackage implements CompletePackageInterface */ protected function replaceSelfVersionDependencies(array $links, $linkType) { - // for self.version requirements, we use the original package's branch name instead of 9999999-dev, to avoid leaking 9999999-dev to users + // for self.version requirements, we use the original package's branch name instead, to avoid leaking the magic dev-master-alias to users $prettyVersion = $this->prettyVersion; - if ($prettyVersion === '9999999-dev') { + if ($prettyVersion === VersionParser::DEV_MASTER_ALIAS) { $prettyVersion = $this->aliasOf->getPrettyVersion(); } diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 2b31db793..53270e601 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -90,8 +90,8 @@ class ArrayLoader implements LoaderInterface if (isset($config['version_normalized'])) { $version = $config['version_normalized']; - // handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained 9999999-dev, we renormalize it - if ($version === '9999999-dev') { + // handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEV_MASTER_ALIAS, we renormalize it + if ($version === VersionParser::DEV_MASTER_ALIAS) { $version = $this->versionParser->normalize($config['version']); } } else { @@ -362,7 +362,7 @@ class ArrayLoader implements LoaderInterface } if (in_array($config['version'], array('dev-master', 'dev-default', 'dev-trunk'), true)) { - return '9999999-dev'; + return VersionParser::DEV_MASTER_ALIAS; } } } diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php index 5bd52b218..c86396ca2 100644 --- a/src/Composer/Package/Version/VersionGuesser.php +++ b/src/Composer/Package/Version/VersionGuesser.php @@ -20,6 +20,8 @@ use Composer\Util\Git as GitUtil; use Composer\Util\HttpDownloader; use Composer\Util\ProcessExecutor; use Composer\Util\Svn as SvnUtil; +use Composer\Package\Version\VersionParser; + /** * Try to guess the current version number based on different VCS configuration. @@ -206,7 +208,7 @@ class VersionGuesser $version = $this->versionParser->normalizeBranch($branch); $isFeatureBranch = 0 === strpos($version, 'dev-'); - if ('9999999-dev' === $version) { + if (VersionParser::DEV_MASTER_ALIAS === $version) { return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch); } diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 3c0a3aff5..29bdab37b 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -18,6 +18,8 @@ use Composer\Semver\Semver; class VersionParser extends SemverVersionParser { + const DEV_MASTER_ALIAS = '9999999-dev'; + private static $constraints = array(); /** @@ -70,8 +72,8 @@ class VersionParser extends SemverVersionParser */ public static function isUpgrade($normalizedFrom, $normalizedTo) { - $normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), '9999999-dev', $normalizedFrom); - $normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), '9999999-dev', $normalizedTo); + $normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEV_MASTER_ALIAS, $normalizedFrom); + $normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEV_MASTER_ALIAS, $normalizedTo); if (substr($normalizedFrom, 0, 4) === 'dev-' || substr($normalizedTo, 0, 4) === 'dev-') { return true; diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 8ba4b8b8c..6fc8a2a85 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -586,8 +586,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito if (!isset($versionsToLoad[$version['uid']])) { if (!isset($version['version_normalized'])) { $version['version_normalized'] = $this->versionParser->normalize($version['version']); - } elseif ($version['version_normalized'] === '9999999-dev') { - // handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained 9999999-dev, we renormalize it + } elseif ($version['version_normalized'] === VersionParser::DEV_MASTER_ALIAS) { + // handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEV_MASTER_ALIAS, we renormalize it $version['version_normalized'] = $this->versionParser->normalize($version['version']); } @@ -707,8 +707,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito foreach ($versions as $version) { if (!isset($version['version_normalized'])) { $version['version_normalized'] = $repo->versionParser->normalize($version['version']); - } elseif ($version['version_normalized'] === '9999999-dev') { - // handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained 9999999-dev, we renormalize it + } elseif ($version['version_normalized'] === VersionParser::DEV_MASTER_ALIAS) { + // handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEV_MASTER_ALIAS, we renormalize it $version['version_normalized'] = $repo->versionParser->normalize($version['version']); } diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index d0aeea878..95bb422d2 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -279,7 +279,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt if ($branch === 'trunk' && isset($branches['master'])) { if ($isVeryVerbose) { - $this->io->writeError('Skipped branch '.$branch.', can not parse both master and trunk branches as they both resolve to 9999999-dev internally'); + $this->io->writeError('Skipped branch '.$branch.', can not parse both master and trunk branches as they both resolve to '.VersionParser::DEV_MASTER_ALIAS.' internally'); } continue; } @@ -292,7 +292,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt } // make sure branch packages have a dev flag - if ('dev-' === substr($parsedBranch, 0, 4) || '9999999-dev' === $parsedBranch) { + if ('dev-' === substr($parsedBranch, 0, 4) || VersionParser::DEV_MASTER_ALIAS === $parsedBranch) { $version = 'dev-' . $branch; } else { $prefix = substr($branch, 0, 1) === 'v' ? 'v' : ''; diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index 63177bdcd..6e4ab7cc3 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -49,9 +49,9 @@ class VersionParserTest extends TestCase return array( array('0.9.0.0', '1.0.0.0', true), array('1.0.0.0', '0.9.0.0', false), - array('1.0.0.0', '9999999-dev', true), - array('9999999-dev', '9999999-dev', true), - array('9999999-dev', '1.0.0.0', false), + array('1.0.0.0', VersionParser::DEV_MASTER_ALIAS, true), + array(VersionParser::DEV_MASTER_ALIAS, VersionParser::DEV_MASTER_ALIAS, true), + array(VersionParser::DEV_MASTER_ALIAS, '1.0.0.0', false), array('1.0.0.0', 'dev-foo', true), array('dev-foo', 'dev-foo', true), array('dev-foo', '1.0.0.0', true),