Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -3,6 +3,36 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
### [1.4.2] 2016-08-30
* Fixed: collapsing of complex constraints lead to buggy constraints
### [1.4.1] 2016-06-02
* Changed: branch-like requirements no longer strip build metadata - [composer/semver#38](https://github.com/composer/semver/pull/38).
### [1.4.0] 2016-03-30
* Added: getters on MultiConstraint - [composer/semver#35](https://github.com/composer/semver/pull/35).
### [1.3.0] 2016-02-25
* Fixed: stability parsing - [composer/composer#1234](https://github.com/composer/composer/issues/4889).
* Changed: collapse contiguous constraints when possible.
### [1.2.0] 2015-11-10
* Changed: allow multiple numerical identifiers in 'pre-release' version part.
* Changed: add more 'v' prefix support.
### [1.1.0] 2015-11-03
* Changed: dropped redundant `test` namespace.
* Changed: minor adjustment in datetime parsing normalization.
* Changed: `ConstraintInterface` relaxed, setPrettyString is not required anymore.
* Changed: `AbstractConstraint` marked deprecated, will be removed in 2.0.
* Changed: `Constraint` is now extensible.
### [1.0.0] 2015-09-21
* Break: `VersionConstraint` renamed to `Constraint`.
@ -13,7 +43,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Changed: `VersionParser::parseConstraints` allows (but ignores) prefixing numeric versions with a 'v' now.
* Changed: Fixed namespace(s) of test files.
* Changed: `Comparator::compare` no longer throws `InvalidArgumentException`.
* Changed: `VersionConstraint` now throws `InvalidArgumentException`.
* Changed: `Constraint` now throws `InvalidArgumentException`.
### [0.1.0] 2015-07-23
@ -26,3 +56,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Namespace: `Composer\Test\Package\Version` -> `Composer\Test\Semver`
- Namespace: `Composer\Test\Package\LinkConstraint` -> `Composer\Test\Semver\Constraint`
* Changed: code style using php-cs-fixer.
[1.4.1]: https://github.com/composer/semver/compare/1.4.0...1.4.1
[1.4.0]: https://github.com/composer/semver/compare/1.3.0...1.4.0
[1.3.0]: https://github.com/composer/semver/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/composer/semver/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/composer/semver/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/composer/semver/compare/0.1.0...1.0.0
[0.1.0]: https://github.com/composer/semver/compare/5e0b9a4da...0.1.0

View file

@ -56,10 +56,10 @@ Comparator::greaterThan('1.25.0', '1.24.0'); // 1.25.0 > 1.24.0
### Semver
The `Composer\Semver\Semver` class providers the following methods:
The `Composer\Semver\Semver` class provides the following methods:
* satisfies($version, $constraints)
* satisfiedBy($constraint, array $versions)
* satisfiedBy(array $versions, $constraint)
* sort($versions)
* rsort($versions)

View file

@ -22,7 +22,8 @@
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com"
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"support": {
@ -30,11 +31,11 @@
"issues": "https://github.com/composer/semver/issues"
},
"require": {
"php": ">=5.3.2"
"php": "^5.3.2 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "~2.3"
"phpunit/phpunit": "^4.5 || ^5.0.5",
"phpunit/phpunit-mock-objects": "2.3.0 || ^3.0"
},
"autoload": {
"psr-4": {
@ -43,12 +44,12 @@
},
"autoload-dev": {
"psr-4": {
"Composer\\Semver\\Test\\": "tests"
"Composer\\Semver\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
"dev-master": "1.x-dev"
}
},
"scripts": {

View file

@ -11,6 +11,8 @@
namespace Composer\Semver\Constraint;
trigger_error('The ' . __CLASS__ . ' abstract class is deprecated, there is no replacement for it, it will be removed in the next major version.', E_USER_DEPRECATED);
/**
* Base constraint class.
*/
@ -26,17 +28,13 @@ abstract class AbstractConstraint implements ConstraintInterface
*/
public function matches(ConstraintInterface $provider)
{
if ($provider instanceof MultiConstraint) {
// turn matching around to find a match
return $provider->matches($this);
}
if ($provider instanceof $this) {
// see note at bottom of this class declaration
return $this->matchSpecific($provider);
}
return true;
// turn matching around to find a match
return $provider->matches($this);
}
/**

View file

@ -14,7 +14,7 @@ namespace Composer\Semver\Constraint;
/**
* Defines a constraint.
*/
class Constraint extends AbstractConstraint
class Constraint implements ConstraintInterface
{
/* operator integer values */
const OP_EQ = 0;
@ -55,10 +55,48 @@ class Constraint extends AbstractConstraint
);
/** @var string */
private $operator;
protected $operator;
/** @var string */
private $version;
protected $version;
/** @var string */
protected $prettyString;
/**
* @param ConstraintInterface $provider
*
* @return bool
*/
public function matches(ConstraintInterface $provider)
{
if ($provider instanceof $this) {
return $this->matchSpecific($provider);
}
// turn matching around to find a match
return $provider->matches($this);
}
/**
* @param string $prettyString
*/
public function setPrettyString($prettyString)
{
$this->prettyString = $prettyString;
}
/**
* @return string
*/
public function getPrettyString()
{
if ($this->prettyString) {
return $this->prettyString;
}
return $this->__toString();
}
/**
* Get all supported comparison operators.

View file

@ -20,11 +20,6 @@ interface ConstraintInterface
*/
public function matches(ConstraintInterface $provider);
/**
* @param string $prettyString
*/
public function setPrettyString($prettyString);
/**
* @return string
*/

View file

@ -35,6 +35,30 @@ class MultiConstraint implements ConstraintInterface
$this->conjunctive = $conjunctive;
}
/**
* @return ConstraintInterface[]
*/
public function getConstraints()
{
return $this->constraints;
}
/**
* @return bool
*/
public function isConjunctive()
{
return $this->conjunctive;
}
/**
* @return bool
*/
public function isDisjunctive()
{
return !$this->conjunctive;
}
/**
* @param ConstraintInterface $provider
*

View file

@ -23,13 +23,23 @@ use Composer\Semver\Constraint\Constraint;
*/
class VersionParser
{
/** @var string */
private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
/**
* Regex to match pre-release data (sort of).
*
* Due to backwards compatibility:
* - Instead of enforcing hyphen, an underscore, dot or nothing at all are also accepted.
* - Only stabilities as recognized by Composer are allowed to precede a numerical identifier.
* - Numerical-only pre-release identifiers are not supported, see tests.
*
* |--------------|
* [major].[minor].[patch] -[pre-release] +[build-metadata]
*
* @var string
*/
private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
/** @var array */
private static $stabilities = array(
'stable', 'RC', 'beta', 'alpha', 'dev',
);
private static $stabilities = array('stable', 'RC', 'beta', 'alpha', 'dev');
/**
* Returns the stability of a version.
@ -46,7 +56,7 @@ class VersionParser
return 'dev';
}
preg_match('{' . self::$modifierRegex . '$}i', strtolower($version), $match);
preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
if (!empty($match[3])) {
return 'dev';
}
@ -96,12 +106,7 @@ class VersionParser
}
// strip off aliasing
if (preg_match('{^([^,\s]+) +as +([^,\s]+)$}', $version, $match)) {
$version = $match[1];
}
// strip off build metadata
if (preg_match('{^([^,\s+]+)\+[^\s]+$}', $version, $match)) {
if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
$version = $match[1];
}
@ -110,12 +115,18 @@ class VersionParser
return '9999999-dev';
}
// if requirement is branch-like, use full name
if ('dev-' === strtolower(substr($version, 0, 4))) {
return 'dev-' . substr($version, 4);
}
// strip off build metadata
if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
$version = $match[1];
}
// match classical versioning
if (preg_match('{^v?(\d{1,5})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) {
if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = $matches[1]
. (!empty($matches[2]) ? $matches[2] : '.0')
. (!empty($matches[3]) ? $matches[3] : '.0')
@ -123,7 +134,7 @@ class VersionParser
$index = 5;
// match date(time) based versioning
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = preg_replace('{\D}', '-', $matches[1]);
$version = preg_replace('{\D}', '.', $matches[1]);
$index = 2;
}
@ -133,7 +144,7 @@ class VersionParser
if ('stable' === $matches[$index]) {
return $version;
}
$version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? $matches[$index + 1] : '');
$version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? ltrim($matches[$index + 1], '.-') : '');
}
if (!empty($matches[$index + 2])) {
@ -170,7 +181,7 @@ class VersionParser
*/
public function parseNumericAliasPrefix($branch)
{
if (preg_match('{^(?P<version>(\d+\\.)*\d+)(?:\.x)?-dev$}i', $branch, $matches)) {
if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
return $matches['version'] . '.';
}
@ -192,7 +203,7 @@ class VersionParser
return $this->normalize($name);
}
if (preg_match('{^v?(\d+)(\.(?:\d+|[xX*]))?(\.(?:\d+|[xX*]))?(\.(?:\d+|[xX*]))?$}i', $name, $matches)) {
if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
$version = '';
for ($i = 1; $i < 5; ++$i) {
$version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
@ -205,7 +216,7 @@ class VersionParser
}
/**
* Parses as constraint string into LinkConstraint objects.
* Parses a constraint string into MultiConstraint and/or Constraint objects.
*
* @param string $constraints
*
@ -249,6 +260,23 @@ class VersionParser
if (1 === count($orGroups)) {
$constraint = $orGroups[0];
} elseif (2 === count($orGroups)
// parse the two OR groups and if they are contiguous we collapse
// them into one constraint
&& $orGroups[0] instanceof MultiConstraint
&& $orGroups[1] instanceof MultiConstraint
&& 2 === count($orGroups[0]->getConstraints())
&& 2 === count($orGroups[1]->getConstraints())
&& ($a = (string) $orGroups[0])
&& substr($a, 0, 3) === '[>=' && (false !== ($posA = strpos($a, '<', 4)))
&& ($b = (string) $orGroups[1])
&& substr($b, 0, 3) === '[>=' && (false !== ($posB = strpos($b, '<', 4)))
&& substr($a, $posA + 2, -1) === substr($b, 4, $posB - 5)
) {
$constraint = new MultiConstraint(array(
new Constraint('>=', substr($a, 4, $posA - 5)),
new Constraint('<', substr($b, $posB + 2, -1)),
));
} else {
$constraint = new MultiConstraint($orGroups, false);
}
@ -274,11 +302,11 @@ class VersionParser
}
}
if (preg_match('{^[xX*](\.[xX*])*$}i', $constraint)) {
if (preg_match('{^v?[xX*](\.[xX*])*$}i', $constraint)) {
return array(new EmptyConstraint());
}
$versionRegex = 'v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?' . self::$modifierRegex . '(?:\+[^\s]+)?';
$versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?' . self::$modifierRegex . '(?:\+[^\s]+)?';
// Tilde Range
//
@ -372,7 +400,7 @@ class VersionParser
//
// Any of X, x, or * may be used to "stand in" for one of the numeric values in the [major, minor, patch] tuple.
// A partial version range is treated as an X-Range, so the special character is in fact optional.
if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.[xX*])+$}', $constraint, $matches)) {
if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
if (isset($matches[3]) && '' !== $matches[3]) {
$position = 3;
} elseif (isset($matches[2]) && '' !== $matches[2]) {