From e17c082366b43f09a1388b7ff4345e42892f0acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Sat, 28 May 2016 16:33:49 +0200 Subject: [PATCH] Fix conversion of version with only major version --- Converter/SemverConverter.php | 2 ++ Tests/Converter/SemverConverterTest.php | 1 + 2 files changed, 3 insertions(+) diff --git a/Converter/SemverConverter.php b/Converter/SemverConverter.php index c6c21202..6edd28d6 100644 --- a/Converter/SemverConverter.php +++ b/Converter/SemverConverter.php @@ -179,6 +179,8 @@ protected function matchRangeTokenStep4($i, $match, array &$matches, &$special, $change = count($version) - 2; $version[$change] = intval($version[$change]) + 1; $match = str_replace(array('*', 'x', 'X'), '0', implode('.', $version)); + } elseif (null === $special && $i === 0 && false === strpos($match, '.') && is_numeric($match)) { + $match = '~'.$match; } else { $match = '~' === $special ? str_replace(array('*', 'x', 'X'), '0', $match) : $match; } diff --git a/Tests/Converter/SemverConverterTest.php b/Tests/Converter/SemverConverterTest.php index 3b2c075e..9c844f7b 100644 --- a/Tests/Converter/SemverConverterTest.php +++ b/Tests/Converter/SemverConverterTest.php @@ -105,6 +105,7 @@ public function getTestRanges() array('<=1.2.3', '<=1.2.3'), array('~1.2.3', '~1.2.3'), array('~1', '~1'), + array('1', '~1'), array('^1.2.3', '>=1.2.3,<2.0.0'), array('^1.2', '>=1.2.0,<2.0.0'), array('^1.x', '>=1.0.0,<2.0.0'),