Spaces are now equivalent to comma in constraints and mean AND
parent
029f709300
commit
ca168d478b
|
@ -75,7 +75,7 @@ Version constraints can be specified in a few different ways.
|
||||||
Name | Example | Description
|
Name | Example | Description
|
||||||
-------------- | ------------------------------------------------------------------ | -----------
|
-------------- | ------------------------------------------------------------------ | -----------
|
||||||
Exact version | `1.0.2` | You can specify the exact version of a package.
|
Exact version | `1.0.2` | You can specify the exact version of a package.
|
||||||
Range | `>=1.0` `>=1.0,<2.0` <code>>=1.0,<1.1 | >=1.2</code> | By using comparison operators you can specify ranges of valid versions. Valid operators are `>`, `>=`, `<`, `<=`, `!=`. <br />You can define multiple ranges. Ranges separated by a comma (`,`) will be treated as a **logical AND**. A pipe (<code>|</code>) will be treated as a **logical OR**. AND has higher precedence than OR.
|
Range | `>=1.0` `>=1.0,<2.0` <code>>=1.0,<1.1 | >=1.2</code> | By using comparison operators you can specify ranges of valid versions. Valid operators are `>`, `>=`, `<`, `<=`, `!=`. <br />You can define multiple ranges. Ranges separated by a space (` `) or comma (`,`) will be treated as a **logical AND**. A pipe (<code>|</code>) will be treated as a **logical OR**. AND has higher precedence than OR.
|
||||||
Wildcard | `1.0.*` | You can specify a pattern with a `*` wildcard. `1.0.*` is the equivalent of `>=1.0,<1.1`.
|
Wildcard | `1.0.*` | You can specify a pattern with a `*` wildcard. `1.0.*` is the equivalent of `>=1.0,<1.1`.
|
||||||
Tilde Operator | `~1.2` | Very useful for projects that follow semantic versioning. `~1.2` is equivalent to `>=1.2,<2.0`. For more details, read the next section below.
|
Tilde Operator | `~1.2` | Very useful for projects that follow semantic versioning. `~1.2` is equivalent to `>=1.2,<2.0`. For more details, read the next section below.
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ dependencies from being installed.
|
||||||
Lists packages that conflict with this version of this package. They
|
Lists packages that conflict with this version of this package. They
|
||||||
will not be allowed to be installed together with your package.
|
will not be allowed to be installed together with your package.
|
||||||
|
|
||||||
Note that when specifying ranges like `<1.0, >= 1.1` in a `conflict` link,
|
Note that when specifying ranges like `<1.0 >=1.1` in a `conflict` link,
|
||||||
this will state a conflict with all versions that are less than 1.0 *and* equal
|
this will state a conflict with all versions that are less than 1.0 *and* equal
|
||||||
or newer than 1.1 at the same time, which is probably not what you want. You
|
or newer than 1.1 at the same time, which is probably not what you want. You
|
||||||
probably want to go for `<1.0 | >=1.1` in this case.
|
probably want to go for `<1.0 | >=1.1` in this case.
|
||||||
|
|
|
@ -233,7 +233,7 @@ class VersionParser
|
||||||
$orConstraints = preg_split('{\s*\|\s*}', trim($constraints));
|
$orConstraints = preg_split('{\s*\|\s*}', trim($constraints));
|
||||||
$orGroups = array();
|
$orGroups = array();
|
||||||
foreach ($orConstraints as $constraints) {
|
foreach ($orConstraints as $constraints) {
|
||||||
$andConstraints = preg_split('{\s*,\s*}', $constraints);
|
$andConstraints = preg_split('{(?<!as|[=><])\s*[, ]+\s*(?!as)}', $constraints);
|
||||||
|
|
||||||
if (count($andConstraints) > 1) {
|
if (count($andConstraints) > 1) {
|
||||||
$constraintObjects = array();
|
$constraintObjects = array();
|
||||||
|
|
|
@ -221,6 +221,8 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
||||||
'completes version' => array('=1.0', new VersionConstraint('=', '1.0.0.0')),
|
'completes version' => array('=1.0', new VersionConstraint('=', '1.0.0.0')),
|
||||||
'shorthand beta' => array('1.2.3b5', new VersionConstraint('=', '1.2.3.0-beta5')),
|
'shorthand beta' => array('1.2.3b5', new VersionConstraint('=', '1.2.3.0-beta5')),
|
||||||
'accepts spaces' => array('>= 1.2.3', new VersionConstraint('>=', '1.2.3.0')),
|
'accepts spaces' => array('>= 1.2.3', new VersionConstraint('>=', '1.2.3.0')),
|
||||||
|
'accepts spaces/2' => array('< 1.2.3', new VersionConstraint('<', '1.2.3.0-dev')),
|
||||||
|
'accepts spaces/3' => array('> 1.2.3', new VersionConstraint('>', '1.2.3.0')),
|
||||||
'accepts master' => array('>=dev-master', new VersionConstraint('>=', '9999999-dev')),
|
'accepts master' => array('>=dev-master', new VersionConstraint('>=', '9999999-dev')),
|
||||||
'accepts master/2' => array('dev-master', new VersionConstraint('=', '9999999-dev')),
|
'accepts master/2' => array('dev-master', new VersionConstraint('=', '9999999-dev')),
|
||||||
'accepts arbitrary' => array('dev-feature-a', new VersionConstraint('=', 'dev-feature-a')),
|
'accepts arbitrary' => array('dev-feature-a', new VersionConstraint('=', 'dev-feature-a')),
|
||||||
|
@ -291,13 +293,27 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParseConstraintsMulti()
|
/**
|
||||||
|
* @dataProvider multiConstraintProvider
|
||||||
|
*/
|
||||||
|
public function testParseConstraintsMulti($constraint)
|
||||||
{
|
{
|
||||||
$parser = new VersionParser;
|
$parser = new VersionParser;
|
||||||
$first = new VersionConstraint('>', '2.0.0.0');
|
$first = new VersionConstraint('>', '2.0.0.0');
|
||||||
$second = new VersionConstraint('<=', '3.0.0.0');
|
$second = new VersionConstraint('<=', '3.0.0.0');
|
||||||
$multi = new MultiConstraint(array($first, $second));
|
$multi = new MultiConstraint(array($first, $second));
|
||||||
$this->assertSame((string) $multi, (string) $parser->parseConstraints('>2.0,<=3.0'));
|
$this->assertSame((string) $multi, (string) $parser->parseConstraints($constraint));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function multiConstraintProvider()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('>2.0,<=3.0'),
|
||||||
|
array('>2.0 <=3.0'),
|
||||||
|
array('>2.0, <=3.0'),
|
||||||
|
array('>2.0 ,<=3.0'),
|
||||||
|
array('>2.0 , <=3.0'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParseConstraintsMultiWithStabilitySuffix()
|
public function testParseConstraintsMultiWithStabilitySuffix()
|
||||||
|
|
Loading…
Reference in New Issue