diff --git a/src/Intervals.php b/src/Intervals.php index a4800c5d..1329800d 100644 --- a/src/Intervals.php +++ b/src/Intervals.php @@ -481,6 +481,11 @@ private static function generateSingleConstraintIntervals(Constraint $constraint return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev()); } if ($op[0] === '<') { // < & <= + // filter out the invalid interval >= 0.0.0.0-dev - < 0.0.0.0-dev + if ($op === '<' && $constraint->getVersion() === '0.0.0.0-dev') { + return array('numeric' => array(), 'branches' => Interval::noDev()); + } + return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev()); } if ($op === '!=') { diff --git a/tests/IntervalsTest.php b/tests/IntervalsTest.php index bbc22771..7cd1189e 100644 --- a/tests/IntervalsTest.php +++ b/tests/IntervalsTest.php @@ -841,6 +841,10 @@ public static function intervalsProvider() self::INTERVAL_ANY, '== dev-foo || != dev-bar || != dev-foo' ), + 'less than zero results in no interval' => array( + self::INTERVAL_NONE, + '< 0.0.0' + ), 'match-none constraints result in no interval' => array( self::INTERVAL_NONE, new MatchNoneConstraint diff --git a/tests/SubsetsTest.php b/tests/SubsetsTest.php index 72f8d74d..9137b17e 100644 --- a/tests/SubsetsTest.php +++ b/tests/SubsetsTest.php @@ -63,6 +63,8 @@ public static function subsets() array('= dev-foo', '= dev-foo'), array('!= dev-foo', '!= dev-foo'), array('< dev-foo', '= dev-foo'), // invalid range matches nothing so is a subset of any other + array('< 0.0.0', '< 0.0.0'), // empty numeric range matches nothing so is a subset of itself + array('< 0.0.0', '^1.0'), array('1.5.*', '^1.4'), array('1.5.*', '1.3 - 1.6 || 1.8 - 1.9'), array('1.3.2', '1.3.0 || 1.3.1 || 1.3.2'),