Laravel 5.6 updates

Travis config update

Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -1,8 +1,19 @@
<?php
namespace PharIo\Version;
class PreReleaseSuffix
{
class PreReleaseSuffix {
private $valueScoreMap = [
'dev' => 0,
'a' => 1,
'alpha' => 1,
'b' => 2,
'beta' => 2,
'rc' => 3,
'p' => 4,
'patch' => 4,
];
/**
* @var string
*/
@@ -11,31 +22,74 @@ class PreReleaseSuffix
/**
* @var int
*/
private $number;
private $valueScore;
/**
* @param string $value
* @param int|null $number
* @var int
*/
public function __construct($value, $number = null)
{
$this->value = $value;
$this->number = $number;
private $number = 0;
/**
* @param string $value
*/
public function __construct($value) {
$this->parseValue($value);
}
/**
* @return string
*/
public function getValue()
{
public function getValue() {
return $this->value;
}
/**
* @return int|null
*/
public function getNumber()
{
public function getNumber() {
return $this->number;
}
/**
* @param PreReleaseSuffix $suffix
*
* @return bool
*/
public function isGreaterThan(PreReleaseSuffix $suffix) {
if ($this->valueScore > $suffix->valueScore) {
return true;
}
if ($this->valueScore < $suffix->valueScore) {
return false;
}
return $this->getNumber() > $suffix->getNumber();
}
/**
* @param $value
*
* @return int
*/
private function mapValueToScore($value) {
if (array_key_exists($value, $this->valueScoreMap)) {
return $this->valueScoreMap[$value];
}
return 0;
}
private function parseValue($value) {
$regex = '/-?(dev|beta|b|rc|alpha|a|patch|p)\.?(\d*).*$/i';
if (preg_match($regex, $value, $matches) !== 1) {
throw new InvalidPreReleaseSuffixException(sprintf('Invalid label %s', $value));
}
$this->value = $matches[1];
if (isset($matches[2])) {
$this->number = (int)$matches[2];
}
$this->valueScore = $this->mapValueToScore($this->value);
}
}

View File

@@ -45,26 +45,10 @@ class Version {
$this->versionString = $versionString;
}
/**
* @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);
if (isset($matches['ReleaseType'])) {
$preReleaseNumber = isset($matches['ReleaseTypeCount']) ? (int) $matches['ReleaseTypeCount'] : null;
$this->preReleaseSuffix = new PreReleaseSuffix($matches['ReleaseType'], $preReleaseNumber);
}
}
/**
* @return PreReleaseSuffix
*/
public function getPreReleaseSuffix()
{
public function getPreReleaseSuffix() {
return $this->preReleaseSuffix;
}
@@ -75,6 +59,13 @@ class Version {
return $this->versionString;
}
/**
* @return bool
*/
public function hasPreReleaseSuffix() {
return $this->preReleaseSuffix !== null;
}
/**
* @param Version $version
*
@@ -97,7 +88,7 @@ class Version {
return true;
}
if ($version->getPatch()->getValue() >= $this->getPatch()->getValue()) {
if ($version->getPatch()->getValue() > $this->getPatch()->getValue()) {
return false;
}
@@ -105,7 +96,19 @@ class Version {
return true;
}
return false;
if (!$version->hasPreReleaseSuffix() && !$this->hasPreReleaseSuffix()) {
return false;
}
if ($version->hasPreReleaseSuffix() && !$this->hasPreReleaseSuffix()) {
return true;
}
if (!$version->hasPreReleaseSuffix() && $this->hasPreReleaseSuffix()) {
return false;
}
return $this->getPreReleaseSuffix()->isGreaterThan($version->getPreReleaseSuffix());
}
/**
@@ -129,6 +132,19 @@ class Version {
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);
if (isset($matches['PreReleaseSuffix'])) {
$this->preReleaseSuffix = new PreReleaseSuffix($matches['PreReleaseSuffix']);
}
}
/**
* @param string $version
*
@@ -144,10 +160,7 @@ class Version {
)?
(?:
-
(?<ReleaseType>(?:(dev|beta|b|RC|alpha|a|patch|p)))
(?:
(?<ReleaseTypeCount>[0-9])
)?
(?<PreReleaseSuffix>(?:(dev|beta|b|RC|alpha|a|patch|p)\.?\d*))
)?
$/x';

View File

@@ -24,7 +24,7 @@ class VersionConstraintParser {
return $this->handleOrGroup($value);
}
if (!preg_match('/^[\^~\*]?[\d.\*]+$/', $value)) {
if (!preg_match('/^[\^~\*]?[\d.\*]+(?:-.*)?$/', $value)) {
throw new UnsupportedVersionConstraintException(
sprintf('Version constraint %s is not supported.', $value)
);
@@ -45,20 +45,20 @@ class VersionConstraintParser {
if ($version->getMinor()->isAny()) {
return new SpecificMajorVersionConstraint(
$value,
$version->getVersionString(),
$version->getMajor()->getValue()
);
}
if ($version->getPatch()->isAny()) {
return new SpecificMajorAndMinorVersionConstraint(
$value,
$version->getVersionString(),
$version->getMajor()->getValue(),
$version->getMinor()->getValue()
);
}
return new ExactVersionConstraint($value);
return new ExactVersionConstraint($version->getVersionString());
}
/**
@@ -82,7 +82,7 @@ class VersionConstraintParser {
* @return AndVersionConstraintGroup
*/
private function handleTildeOperator($value) {
$version = new Version(substr($value, 1));
$version = new Version(substr($value, 1));
$constraints = [
new GreaterThanOrEqualToVersionConstraint($value, $version)
];

View File

@@ -1,8 +1,8 @@
<?php
namespace PharIo\Version;
class VersionConstraintValue
{
class VersionConstraintValue {
/**
* @var VersionNumber
*/
@@ -42,43 +42,6 @@ class VersionConstraintValue
$this->parseVersion($versionString);
}
/**
* @param $versionString
*/
private function parseVersion($versionString) {
$this->extractBuildMetaData($versionString);
$this->extractLabel($versionString);
$versionSegments = explode('.', $versionString);
$this->major = new VersionNumber($versionSegments[0]);
$minorValue = isset($versionSegments[1]) ? $versionSegments[1] : null;
$patchValue = isset($versionSegments[2]) ? $versionSegments[2] : null;
$this->minor = new VersionNumber($minorValue);
$this->patch = new VersionNumber($patchValue);
}
/**
* @param string $versionString
*/
private function extractBuildMetaData(&$versionString) {
if (preg_match('/\+(.*)/', $versionString, $matches) == 1) {
$this->buildMetaData = $matches[1];
$versionString = str_replace($matches[0], '', $versionString);
}
}
/**
* @param string $versionString
*/
private function extractLabel(&$versionString) {
if (preg_match('/\-(.*)/', $versionString, $matches) == 1) {
$this->label = $matches[1];
$versionString = str_replace($matches[0], '', $versionString);
}
}
/**
* @return string
*/
@@ -120,4 +83,41 @@ class VersionConstraintValue
public function getPatch() {
return $this->patch;
}
/**
* @param $versionString
*/
private function parseVersion($versionString) {
$this->extractBuildMetaData($versionString);
$this->extractLabel($versionString);
$versionSegments = explode('.', $versionString);
$this->major = new VersionNumber($versionSegments[0]);
$minorValue = isset($versionSegments[1]) ? $versionSegments[1] : null;
$patchValue = isset($versionSegments[2]) ? $versionSegments[2] : null;
$this->minor = new VersionNumber($minorValue);
$this->patch = new VersionNumber($patchValue);
}
/**
* @param string $versionString
*/
private function extractBuildMetaData(&$versionString) {
if (preg_match('/\+(.*)/', $versionString, $matches) == 1) {
$this->buildMetaData = $matches[1];
$versionString = str_replace($matches[0], '', $versionString);
}
}
/**
* @param string $versionString
*/
private function extractLabel(&$versionString) {
if (preg_match('/\-(.*)/', $versionString, $matches) == 1) {
$this->label = $matches[1];
$versionString = str_replace($matches[0], '', $versionString);
}
}
}

View File

@@ -17,7 +17,7 @@ class AndVersionConstraintGroup extends AbstractVersionConstraint {
private $constraints = [];
/**
* @param string $originalValue
* @param string $originalValue
* @param VersionConstraint[] $constraints
*/
public function __construct($originalValue, array $constraints) {

View File

@@ -17,7 +17,7 @@ class GreaterThanOrEqualToVersionConstraint extends AbstractVersionConstraint {
private $minimalVersion;
/**
* @param string $originalValue
* @param string $originalValue
* @param Version $minimalVersion
*/
public function __construct($originalValue, Version $minimalVersion) {
@@ -32,7 +32,7 @@ class GreaterThanOrEqualToVersionConstraint extends AbstractVersionConstraint {
* @return bool
*/
public function complies(Version $version) {
return $version->getVersionString() == $this->minimalVersion->getVersionString() ||
$version->isGreaterThan($this->minimalVersion);
return $version->getVersionString() == $this->minimalVersion->getVersionString()
|| $version->isGreaterThan($this->minimalVersion);
}
}

View File

@@ -17,7 +17,7 @@ class OrVersionConstraintGroup extends AbstractVersionConstraint {
private $constraints = [];
/**
* @param string $originalValue
* @param string $originalValue
* @param VersionConstraint[] $constraints
*/
public function __construct($originalValue, array $constraints) {

View File

@@ -23,8 +23,8 @@ class SpecificMajorAndMinorVersionConstraint extends AbstractVersionConstraint {
/**
* @param string $originalValue
* @param int $major
* @param int $minor
* @param int $major
* @param int $minor
*/
public function __construct($originalValue, $major, $minor) {
parent::__construct($originalValue);

View File

@@ -18,7 +18,7 @@ class SpecificMajorVersionConstraint extends AbstractVersionConstraint {
/**
* @param string $originalValue
* @param int $major
* @param int $major
*/
public function __construct($originalValue, $major) {
parent::__construct($originalValue);

View File

@@ -0,0 +1,7 @@
<?php
namespace PharIo\Version;
class InvalidPreReleaseSuffixException extends \Exception implements Exception {
}

View File

@@ -1,4 +1,5 @@
<?php
namespace PharIo\Version;
class InvalidVersionException extends \InvalidArgumentException implements Exception {