From 97dfbefa72ed797d3812f25d013ca610e23a36f0 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 13 Feb 2013 13:26:27 +0100 Subject: [PATCH] Add support for arbitrary values for the references in version constraints --- src/Composer/Package/Version/VersionParser.php | 4 ++-- tests/Composer/Test/Package/Version/VersionParserTest.php | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index fbedc9e33..9c6e35812 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -35,7 +35,7 @@ class VersionParser */ public static function parseStability($version) { - $version = preg_replace('{#[a-f0-9]+$}i', '', $version); + $version = preg_replace('{#.+$}i', '', $version); if ('dev-' === substr($version, 0, 4) || '-dev' === substr($version, -4)) { return 'dev'; @@ -217,7 +217,7 @@ class VersionParser $constraints = empty($match[1]) ? '*' : $match[1]; } - if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#[a-f0-9]+$}i', $constraints, $match)) { + if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraints, $match)) { $constraints = $match[1]; } diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index d62a8df5c..139cee02a 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -165,6 +165,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase { $parser = new VersionParser; $this->assertSame((string) new VersionConstraint('=', '1.0.9999999.9999999-dev'), (string) $parser->parseConstraints('1.0.x-dev#abcd123')); + $this->assertSame((string) new VersionConstraint('=', '1.0.9999999.9999999-dev'), (string) $parser->parseConstraints('1.0.x-dev#trunk/@123')); } /** @@ -174,6 +175,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase { $parser = new VersionParser; $this->assertSame((string) new VersionConstraint('=', '1.0.0.0'), (string) $parser->parseConstraints('1.0#abcd123')); + $this->assertSame((string) new VersionConstraint('=', '1.0.0.0'), (string) $parser->parseConstraints('1.0#trunk/@123')); } /** @@ -320,6 +322,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase array('stable', '1.0'), array('dev', 'v2.0.x-dev'), array('dev', 'v2.0.x-dev#abc123'), + array('dev', 'v2.0.x-dev#trunk/@123'), array('RC', '3.0-RC2'), array('dev', 'dev-master'), array('dev', '3.1.2-dev'),