From dacfc81d781fa31bed37ad385b2658a0ee014b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Wed, 15 Feb 2017 20:54:36 +0100 Subject: [PATCH] Fix conversion of && range version --- Converter/SemverConverter.php | 6 ++++-- Tests/Converter/SemverConverterTest.php | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Converter/SemverConverter.php b/Converter/SemverConverter.php index 91511d1e..8b61727a 100644 --- a/Converter/SemverConverter.php +++ b/Converter/SemverConverter.php @@ -55,13 +55,15 @@ public function convertRange($range) */ protected function cleanRange($range) { - foreach (array('<', '>', '=', '~', '^', '||') as $character) { + foreach (array('<', '>', '=', '~', '^', '||', '&&') as $character) { $range = str_replace($character.' ', $character, $range); } $range = preg_replace('/(?:[vV])(\d+)/', '${1}', $range); + $range = str_replace(' ||', '||', $range); + $range = str_replace(array(' &&', '&&'), ',', $range); - return str_replace(' ||', '||', $range); + return $range; } /** diff --git a/Tests/Converter/SemverConverterTest.php b/Tests/Converter/SemverConverterTest.php index b4b500e7..197a1e6c 100644 --- a/Tests/Converter/SemverConverterTest.php +++ b/Tests/Converter/SemverConverterTest.php @@ -134,6 +134,7 @@ public function getTestRanges() array('>=1.2 <2.0', '>=1.2,<2.0'), array('>=1 <2', '>=1,<2'), array('>=1.0 <1.1 || >=1.2', '>=1.0,<1.1|>=1.2'), + array('>=1.0 && <1.1 || >=1.2', '>=1.0,<1.1|>=1.2'), array('< 1.2.3', '<1.2.3'), array('> 1.2.3', '>1.2.3'), array('<= 1.2.3', '<=1.2.3'),