upgrade to laravel 7 and set branch to v2

This commit is contained in:
2020-12-25 11:22:15 +00:00
parent 516105c492
commit 0ddd298350
4638 changed files with 132501 additions and 190226 deletions
+40 -67
View File
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Version.
*
@@ -7,71 +7,56 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
class Version {
/**
* @var VersionNumber
*/
/** @var VersionNumber */
private $major;
/**
* @var VersionNumber
*/
/** @var VersionNumber */
private $minor;
/**
* @var VersionNumber
*/
/** @var VersionNumber */
private $patch;
/**
* @var PreReleaseSuffix
*/
/** @var PreReleaseSuffix */
private $preReleaseSuffix;
/**
* @var string
*/
private $versionString = '';
/**
* @param string $versionString
*/
public function __construct($versionString) {
$this->ensureVersionStringIsValid($versionString);
$this->versionString = $versionString;
}
/**
* @return PreReleaseSuffix
*/
public function getPreReleaseSuffix() {
public function getPreReleaseSuffix(): PreReleaseSuffix {
return $this->preReleaseSuffix;
}
/**
* @return string
*/
public function getVersionString() {
return $this->versionString;
public function getVersionString(): string {
$str = sprintf(
'%d.%d.%d',
$this->getMajor()->getValue(),
$this->getMinor()->getValue(),
$this->getPatch()->getValue()
);
if (!$this->hasPreReleaseSuffix()) {
return $str;
}
return $str . '-' . $this->getPreReleaseSuffix()->asString();
}
/**
* @return bool
*/
public function hasPreReleaseSuffix() {
public function hasPreReleaseSuffix(): bool {
return $this->preReleaseSuffix !== null;
}
/**
* @param Version $version
*
* @return bool
*/
public function isGreaterThan(Version $version) {
public function equals(Version $other): bool {
return $this->getVersionString() === $other->getVersionString();
}
public function isGreaterThan(Version $version): bool {
if ($version->getMajor()->getValue() > $this->getMajor()->getValue()) {
return false;
}
@@ -111,34 +96,22 @@ class Version {
return $this->getPreReleaseSuffix()->isGreaterThan($version->getPreReleaseSuffix());
}
/**
* @return VersionNumber
*/
public function getMajor() {
public function getMajor(): VersionNumber {
return $this->major;
}
/**
* @return VersionNumber
*/
public function getMinor() {
public function getMinor(): VersionNumber {
return $this->minor;
}
/**
* @return VersionNumber
*/
public function getPatch() {
public function getPatch(): VersionNumber {
return $this->patch;
}
/**
* @param array $matches
*/
private function parseVersion(array $matches) {
$this->major = new VersionNumber($matches['Major']);
$this->minor = new VersionNumber($matches['Minor']);
$this->patch = isset($matches['Patch']) ? new VersionNumber($matches['Patch']) : new VersionNumber(null);
private function parseVersion(array $matches): void {
$this->major = new VersionNumber((int)$matches['Major']);
$this->minor = new VersionNumber((int)$matches['Minor']);
$this->patch = isset($matches['Patch']) ? new VersionNumber((int)$matches['Patch']) : new VersionNumber(0);
if (isset($matches['PreReleaseSuffix'])) {
$this->preReleaseSuffix = new PreReleaseSuffix($matches['PreReleaseSuffix']);
@@ -150,23 +123,23 @@ class Version {
*
* @throws InvalidVersionException
*/
private function ensureVersionStringIsValid($version) {
private function ensureVersionStringIsValid($version): void {
$regex = '/^v?
(?<Major>(0|(?:[1-9][0-9]*)))
(?<Major>(0|(?:[1-9]\d*)))
\\.
(?<Minor>(0|(?:[1-9][0-9]*)))
(?<Minor>(0|(?:[1-9]\d*)))
(\\.
(?<Patch>(0|(?:[1-9][0-9]*)))
(?<Patch>(0|(?:[1-9]\d*)))
)?
(?:
-
(?<PreReleaseSuffix>(?:(dev|beta|b|RC|alpha|a|patch|p)\.?\d*))
(?<PreReleaseSuffix>(?:(dev|beta|b|rc|alpha|a|patch|p)\.?\d*))
)?
$/x';
$/xi';
if (preg_match($regex, $version, $matches) !== 1) {
if (\preg_match($regex, $version, $matches) !== 1) {
throw new InvalidVersionException(
sprintf("Version string '%s' does not follow SemVer semantics", $version)
\sprintf("Version string '%s' does not follow SemVer semantics", $version)
);
}