Composer upgrade
This commit is contained in:
28
www/vendor/phar-io/version/src/BuildMetaData.php
vendored
Normal file
28
www/vendor/phar-io/version/src/BuildMetaData.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PharIo\Version;
|
||||
|
||||
class BuildMetaData {
|
||||
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
public function __construct(string $value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function asString(): string {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function equals(BuildMetaData $other): bool {
|
||||
return $this->asString() === $other->asString();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ class PreReleaseSuffix {
|
||||
'beta' => 2,
|
||||
'rc' => 3,
|
||||
'p' => 4,
|
||||
'pl' => 4,
|
||||
'patch' => 4,
|
||||
];
|
||||
|
||||
@@ -59,15 +60,11 @@ class PreReleaseSuffix {
|
||||
private function mapValueToScore(string $value): int {
|
||||
$value = \strtolower($value);
|
||||
|
||||
if (\array_key_exists($value, self::valueScoreMap)) {
|
||||
return self::valueScoreMap[$value];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return self::valueScoreMap[$value];
|
||||
}
|
||||
|
||||
private function parseValue(string $value): void {
|
||||
$regex = '/-?((dev|beta|b|rc|alpha|a|patch|p)\.?(\d*)).*$/i';
|
||||
$regex = '/-?((dev|beta|b|rc|alpha|a|patch|p|pl)\.?(\d*)).*$/i';
|
||||
|
||||
if (\preg_match($regex, $value, $matches) !== 1) {
|
||||
throw new InvalidPreReleaseSuffixException(\sprintf('Invalid label %s', $value));
|
||||
|
||||
60
www/vendor/phar-io/version/src/Version.php
vendored
60
www/vendor/phar-io/version/src/Version.php
vendored
@@ -25,11 +25,17 @@ class Version {
|
||||
/** @var null|PreReleaseSuffix */
|
||||
private $preReleaseSuffix;
|
||||
|
||||
/** @var null|BuildMetaData */
|
||||
private $buildMetadata;
|
||||
|
||||
public function __construct(string $versionString) {
|
||||
$this->ensureVersionStringIsValid($versionString);
|
||||
$this->originalVersionString = $versionString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NoPreReleaseSuffixException
|
||||
*/
|
||||
public function getPreReleaseSuffix(): PreReleaseSuffix {
|
||||
if ($this->preReleaseSuffix === null) {
|
||||
throw new NoPreReleaseSuffixException('No pre-release suffix set');
|
||||
@@ -62,7 +68,20 @@ class Version {
|
||||
}
|
||||
|
||||
public function equals(Version $other): bool {
|
||||
return $this->getVersionString() === $other->getVersionString();
|
||||
if ($this->getVersionString() !== $other->getVersionString()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->hasBuildMetaData() !== $other->hasBuildMetaData()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->hasBuildMetaData() && $other->hasBuildMetaData() &&
|
||||
!$this->getBuildMetaData()->equals($other->getBuildMetaData())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isGreaterThan(Version $version): bool {
|
||||
@@ -117,6 +136,25 @@ class Version {
|
||||
return $this->patch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-assert-if-true BuildMetaData $this->buildMetadata
|
||||
* @psalm-assert-if-true BuildMetaData $this->getBuildMetaData()
|
||||
*/
|
||||
public function hasBuildMetaData(): bool {
|
||||
return $this->buildMetadata !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NoBuildMetaDataException
|
||||
*/
|
||||
public function getBuildMetaData(): BuildMetaData {
|
||||
if (!$this->hasBuildMetaData()) {
|
||||
throw new NoBuildMetaDataException('No build metadata set');
|
||||
}
|
||||
|
||||
return $this->buildMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $matches
|
||||
*
|
||||
@@ -127,9 +165,13 @@ class Version {
|
||||
$this->minor = new VersionNumber((int)$matches['Minor']);
|
||||
$this->patch = isset($matches['Patch']) ? new VersionNumber((int)$matches['Patch']) : new VersionNumber(0);
|
||||
|
||||
if (isset($matches['PreReleaseSuffix'])) {
|
||||
if (isset($matches['PreReleaseSuffix']) && $matches['PreReleaseSuffix'] !== '') {
|
||||
$this->preReleaseSuffix = new PreReleaseSuffix($matches['PreReleaseSuffix']);
|
||||
}
|
||||
|
||||
if (isset($matches['BuildMetadata'])) {
|
||||
$this->buildMetadata = new BuildMetaData($matches['BuildMetadata']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,16 +181,20 @@ class Version {
|
||||
*/
|
||||
private function ensureVersionStringIsValid($version): void {
|
||||
$regex = '/^v?
|
||||
(?<Major>(0|(?:[1-9]\d*)))
|
||||
(?P<Major>0|[1-9]\d*)
|
||||
\\.
|
||||
(?<Minor>(0|(?:[1-9]\d*)))
|
||||
(?P<Minor>0|[1-9]\d*)
|
||||
(\\.
|
||||
(?<Patch>(0|(?:[1-9]\d*)))
|
||||
(?P<Patch>0|[1-9]\d*)
|
||||
)?
|
||||
(?:
|
||||
-
|
||||
(?<PreReleaseSuffix>(?:(dev|beta|b|rc|alpha|a|patch|p)\.?\d*))
|
||||
)?
|
||||
(?<PreReleaseSuffix>(?:(dev|beta|b|rc|alpha|a|patch|p|pl)\.?\d*))
|
||||
)?
|
||||
(?:
|
||||
\\+
|
||||
(?P<BuildMetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-@]+)*)
|
||||
)?
|
||||
$/xi';
|
||||
|
||||
if (\preg_match($regex, $version, $matches) !== 1) {
|
||||
|
||||
@@ -14,7 +14,7 @@ class VersionConstraintParser {
|
||||
* @throws UnsupportedVersionConstraintException
|
||||
*/
|
||||
public function parse(string $value): VersionConstraint {
|
||||
if (\strpos($value, '||') !== false) {
|
||||
if (\strpos($value, '|') !== false) {
|
||||
return $this->handleOrGroup($value);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class VersionConstraintParser {
|
||||
private function handleOrGroup(string $value): OrVersionConstraintGroup {
|
||||
$constraints = [];
|
||||
|
||||
foreach (\explode('||', $value) as $groupSegment) {
|
||||
foreach (\preg_split('{\s*\|\|?\s*}', \trim($value)) as $groupSegment) {
|
||||
$constraints[] = $this->parse(\trim($groupSegment));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace PharIo\Version;
|
||||
|
||||
class ExactVersionConstraint extends AbstractVersionConstraint {
|
||||
public function complies(Version $version): bool {
|
||||
return $this->asString() === $version->getVersionString();
|
||||
$other = $version->getVersionString();
|
||||
|
||||
if ($version->hasBuildMetaData()) {
|
||||
$other .= '+' . $version->getBuildMetaData()->asString();
|
||||
}
|
||||
|
||||
return $this->asString() === $other;
|
||||
}
|
||||
}
|
||||
|
||||
5
www/vendor/phar-io/version/src/exceptions/NoBuildMetaDataException.php
vendored
Normal file
5
www/vendor/phar-io/version/src/exceptions/NoBuildMetaDataException.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Version;
|
||||
|
||||
class NoBuildMetaDataException extends \Exception implements Exception {
|
||||
}
|
||||
Reference in New Issue
Block a user