update inbox list

This commit is contained in:
manhlab
2021-04-07 19:25:18 -04:00
parent fda7245f7c
commit 436de2efd6
8576 changed files with 1013325 additions and 3 deletions

7
vendor/phar-io/version/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
/.idea
/.php_cs.cache
/composer.lock
/src/autoload.php
/tools
/vendor

67
vendor/phar-io/version/.php_cs vendored Normal file
View File

@@ -0,0 +1,67 @@
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->files()
->in('src')
->in('tests')
->name('*.php');
return Symfony\CS\Config\Config::create()
->setUsingCache(true)
->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
->fixers(
array(
'align_double_arrow',
'align_equals',
'concat_with_spaces',
'duplicate_semicolon',
'elseif',
'empty_return',
'encoding',
'eof_ending',
'extra_empty_lines',
'function_call_space',
'function_declaration',
'indentation',
'join_function',
'line_after_namespace',
'linefeed',
'list_commas',
'lowercase_constants',
'lowercase_keywords',
'method_argument_space',
'multiple_use',
'namespace_no_leading_whitespace',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
'parenthesis',
'php_closing_tag',
'phpdoc_indent',
'phpdoc_no_access',
'phpdoc_no_empty_return',
'phpdoc_no_package',
'phpdoc_params',
'phpdoc_scalar',
'phpdoc_separation',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_types',
'phpdoc_var_without_name',
'remove_lines_between_uses',
'return',
'self_accessor',
'short_array_syntax',
'short_tag',
'single_line_after_imports',
'single_quote',
'spaces_before_semicolon',
'spaces_cast',
'ternary_spaces',
'trailing_spaces',
'trim_array_spaces',
'unused_use',
'visibility',
'whitespacy_lines'
)
)
->finder($finder);

33
vendor/phar-io/version/.travis.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
os:
- linux
language: php
before_install:
- wget https://phar.io/releases/phive.phar
- wget https://phar.io/releases/phive.phar.asc
- gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys 0x9B2D5D79
- gpg --verify phive.phar.asc phive.phar
- chmod +x phive.phar
- sudo mv phive.phar /usr/bin/phive
install:
- ant setup
script: ./tools/phpunit
php:
- 5.6
- 7.0
- 7.1
- 7.0snapshot
- 7.1snapshot
- master
matrix:
allow_failures:
- php: master
fast_finish: true
notifications:
email: false

44
vendor/phar-io/version/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,44 @@
# Changelog
All notable changes to phar-io/version are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [2.0.1] - 08.07.2018
### Fixed
- Versions without a pre-release suffix are now always considered greater
than versions without a pre-release suffix. Example: `3.0.0 > 3.0.0-alpha.1`
## [2.0.0] - 23.06.2018
Changes to public API:
- `PreReleaseSuffix::construct()`: optional parameter `$number` removed
- `PreReleaseSuffix::isGreaterThan()`: introduced
- `Version::hasPreReleaseSuffix()`: introduced
### Added
- [#11](https://github.com/phar-io/version/issues/11): Added support for pre-release version suffixes. Supported values are:
- `dev`
- `beta` (also abbreviated form `b`)
- `rc`
- `alpha` (also abbreviated form `a`)
- `patch` (also abbreviated form `p`)
All values can be followed by a number, e.g. `beta3`.
When comparing versions, the pre-release suffix is taken into account. Example:
`1.5.0 > 1.5.0-beta1 > 1.5.0-alpha3 > 1.5.0-alpha2 > 1.5.0-dev11`
### Changed
- reorganized the source directories
### Fixed
- [#10](https://github.com/phar-io/version/issues/10): Version numbers containing
a numeric suffix as seen in Debian packages are now supported.
[2.0.1]: https://github.com/phar-io/version/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/phar-io/version/compare/1.0.1...2.0.0

31
vendor/phar-io/version/LICENSE vendored Normal file
View File

@@ -0,0 +1,31 @@
phar-io/version
Copyright (c) 2016-2017 Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de> and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Arne Blankerts nor the names of contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

61
vendor/phar-io/version/README.md vendored Normal file
View File

@@ -0,0 +1,61 @@
# Version
Library for handling version information and constraints
[![Build Status](https://travis-ci.org/phar-io/version.svg?branch=master)](https://travis-ci.org/phar-io/version)
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
composer require phar-io/version
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev phar-io/version
## Version constraints
A Version constraint describes a range of versions or a discrete version number. The format of version numbers follows the schema of [semantic versioning](http://semver.org): `<major>.<minor>.<patch>`. A constraint might contain an operator that describes the range.
Beside the typical mathematical operators like `<=`, `>=`, there are two special operators:
*Caret operator*: `^1.0`
can be written as `>=1.0.0 <2.0.0` and read as »every Version within major version `1`«.
*Tilde operator*: `~1.0.0`
can be written as `>=1.0.0 <1.1.0` and read as »every version within minor version `1.1`. The behavior of tilde operator depends on whether a patch level version is provided or not. If no patch level is provided, tilde operator behaves like the caret operator: `~1.0` is identical to `^1.0`.
## Usage examples
Parsing version constraints and check discrete versions for compliance:
```php
use PharIo\Version\Version;
use PharIo\Version\VersionConstraintParser;
$parser = new VersionConstraintParser();
$caret_constraint = $parser->parse( '^7.0' );
$caret_constraint->complies( new Version( '7.0.17' ) ); // true
$caret_constraint->complies( new Version( '7.1.0' ) ); // true
$caret_constraint->complies( new Version( '6.4.34' ) ); // false
$tilde_constraint = $parser->parse( '~1.1.0' );
$tilde_constraint->complies( new Version( '1.1.4' ) ); // true
$tilde_constraint->complies( new Version( '1.2.0' ) ); // false
```
As of version 2.0.0, pre-release labels are supported and taken into account when comparing versions:
```php
$leftVersion = new PharIo\Version\Version('3.0.0-alpha.1');
$rightVersion = new PharIo\Version\Version('3.0.0-alpha.2');
$leftVersion->isGreaterThan($rightVersion); // false
$rightVersion->isGreaterThan($leftVersion); // true
```

41
vendor/phar-io/version/build.xml vendored Normal file
View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="version" default="setup">
<target name="setup" depends="clean,install-tools,generate-autoloader"/>
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${basedir}/tools"/>
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/src/autoload.php"/>
<property name="clean.done" value="true"/>
</target>
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
<property name="prepare.done" value="true"/>
</target>
<target name="-tools-installed">
<available file="${basedir}/tools" property="tools-installed" type="dir"/>
</target>
<target name="install-tools" unless="tools-installed" depends="-tools-installed" description="Install tools with Phive">
<exec executable="phive" taskname="phive">
<arg value="install"/>
<arg value="--trust-gpg-keys" />
<arg value="4AA394086372C20A,2A8299CE842DD38C" />
</exec>
</target>
<target name="generate-autoloader" depends="install-tools" description="Generate autoloader using PHPAB">
<exec executable="${basedir}/tools/phpab" taskname="phpab">
<arg value="--output"/>
<arg path="${basedir}/src/autoload.php"/>
<arg path="${basedir}/src"/>
</exec>
</target>
<target name="test" depends="generate-autoloader" description="Run tests">
<exec executable="${basedir}/tools/phpunit" taskname="phpunit"/>
</target>
</project>

34
vendor/phar-io/version/composer.json vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "phar-io/version",
"description": "Library for handling version information and constraints",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
},
{
"name": "Sebastian Heuer",
"email": "sebastian@phpeople.de",
"role": "Developer"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/phar-io/version/issues"
},
"require": {
"php": "^5.6 || ^7.0"
},
"autoload": {
"classmap": [
"src/"
]
}
}

5
vendor/phar-io/version/phive.xml vendored Normal file
View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="^5.7.5" installed="5.7.5" location="./tools/phpunit"/>
<phar name="phpab" version="^1.23.0" installed="1.23.0" location="./tools/phpab"/>
</phive>

19
vendor/phar-io/version/phpunit.xml vendored Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
bootstrap="src/autoload.php"
backupGlobals="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite>
<directory suffix="Test.php">tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -0,0 +1,95 @@
<?php
namespace PharIo\Version;
class PreReleaseSuffix {
private $valueScoreMap = [
'dev' => 0,
'a' => 1,
'alpha' => 1,
'b' => 2,
'beta' => 2,
'rc' => 3,
'p' => 4,
'patch' => 4,
];
/**
* @var string
*/
private $value;
/**
* @var int
*/
private $valueScore;
/**
* @var int
*/
private $number = 0;
/**
* @param string $value
*/
public function __construct($value) {
$this->parseValue($value);
}
/**
* @return string
*/
public function getValue() {
return $this->value;
}
/**
* @return int|null
*/
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);
}
}

175
vendor/phar-io/version/src/Version.php vendored Normal file
View File

@@ -0,0 +1,175 @@
<?php
/*
* 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 Version {
/**
* @var VersionNumber
*/
private $major;
/**
* @var VersionNumber
*/
private $minor;
/**
* @var VersionNumber
*/
private $patch;
/**
* @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() {
return $this->preReleaseSuffix;
}
/**
* @return string
*/
public function getVersionString() {
return $this->versionString;
}
/**
* @return bool
*/
public function hasPreReleaseSuffix() {
return $this->preReleaseSuffix !== null;
}
/**
* @param Version $version
*
* @return bool
*/
public function isGreaterThan(Version $version) {
if ($version->getMajor()->getValue() > $this->getMajor()->getValue()) {
return false;
}
if ($version->getMajor()->getValue() < $this->getMajor()->getValue()) {
return true;
}
if ($version->getMinor()->getValue() > $this->getMinor()->getValue()) {
return false;
}
if ($version->getMinor()->getValue() < $this->getMinor()->getValue()) {
return true;
}
if ($version->getPatch()->getValue() > $this->getPatch()->getValue()) {
return false;
}
if ($version->getPatch()->getValue() < $this->getPatch()->getValue()) {
return true;
}
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());
}
/**
* @return VersionNumber
*/
public function getMajor() {
return $this->major;
}
/**
* @return VersionNumber
*/
public function getMinor() {
return $this->minor;
}
/**
* @return VersionNumber
*/
public function getPatch() {
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
*
* @throws InvalidVersionException
*/
private function ensureVersionStringIsValid($version) {
$regex = '/^v?
(?<Major>(0|(?:[1-9][0-9]*)))
\\.
(?<Minor>(0|(?:[1-9][0-9]*)))
(\\.
(?<Patch>(0|(?:[1-9][0-9]*)))
)?
(?:
-
(?<PreReleaseSuffix>(?:(dev|beta|b|RC|alpha|a|patch|p)\.?\d*))
)?
$/x';
if (preg_match($regex, $version, $matches) !== 1) {
throw new InvalidVersionException(
sprintf("Version string '%s' does not follow SemVer semantics", $version)
);
}
$this->parseVersion($matches);
}
}

View File

@@ -0,0 +1,122 @@
<?php
/*
* 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 VersionConstraintParser {
/**
* @param string $value
*
* @return VersionConstraint
*
* @throws UnsupportedVersionConstraintException
*/
public function parse($value) {
if (strpos($value, '||') !== false) {
return $this->handleOrGroup($value);
}
if (!preg_match('/^[\^~\*]?[\d.\*]+(?:-.*)?$/', $value)) {
throw new UnsupportedVersionConstraintException(
sprintf('Version constraint %s is not supported.', $value)
);
}
switch ($value[0]) {
case '~':
return $this->handleTildeOperator($value);
case '^':
return $this->handleCaretOperator($value);
}
$version = new VersionConstraintValue($value);
if ($version->getMajor()->isAny()) {
return new AnyVersionConstraint();
}
if ($version->getMinor()->isAny()) {
return new SpecificMajorVersionConstraint(
$version->getVersionString(),
$version->getMajor()->getValue()
);
}
if ($version->getPatch()->isAny()) {
return new SpecificMajorAndMinorVersionConstraint(
$version->getVersionString(),
$version->getMajor()->getValue(),
$version->getMinor()->getValue()
);
}
return new ExactVersionConstraint($version->getVersionString());
}
/**
* @param $value
*
* @return OrVersionConstraintGroup
*/
private function handleOrGroup($value) {
$constraints = [];
foreach (explode('||', $value) as $groupSegment) {
$constraints[] = $this->parse(trim($groupSegment));
}
return new OrVersionConstraintGroup($value, $constraints);
}
/**
* @param string $value
*
* @return AndVersionConstraintGroup
*/
private function handleTildeOperator($value) {
$version = new Version(substr($value, 1));
$constraints = [
new GreaterThanOrEqualToVersionConstraint($value, $version)
];
if ($version->getPatch()->isAny()) {
$constraints[] = new SpecificMajorVersionConstraint(
$value,
$version->getMajor()->getValue()
);
} else {
$constraints[] = new SpecificMajorAndMinorVersionConstraint(
$value,
$version->getMajor()->getValue(),
$version->getMinor()->getValue()
);
}
return new AndVersionConstraintGroup($value, $constraints);
}
/**
* @param string $value
*
* @return AndVersionConstraintGroup
*/
private function handleCaretOperator($value) {
$version = new Version(substr($value, 1));
return new AndVersionConstraintGroup(
$value,
[
new GreaterThanOrEqualToVersionConstraint($value, $version),
new SpecificMajorVersionConstraint($value, $version->getMajor()->getValue())
]
);
}
}

View File

@@ -0,0 +1,123 @@
<?php
namespace PharIo\Version;
class VersionConstraintValue {
/**
* @var VersionNumber
*/
private $major;
/**
* @var VersionNumber
*/
private $minor;
/**
* @var VersionNumber
*/
private $patch;
/**
* @var string
*/
private $label = '';
/**
* @var string
*/
private $buildMetaData = '';
/**
* @var string
*/
private $versionString = '';
/**
* @param string $versionString
*/
public function __construct($versionString) {
$this->versionString = $versionString;
$this->parseVersion($versionString);
}
/**
* @return string
*/
public function getLabel() {
return $this->label;
}
/**
* @return string
*/
public function getBuildMetaData() {
return $this->buildMetaData;
}
/**
* @return string
*/
public function getVersionString() {
return $this->versionString;
}
/**
* @return VersionNumber
*/
public function getMajor() {
return $this->major;
}
/**
* @return VersionNumber
*/
public function getMinor() {
return $this->minor;
}
/**
* @return VersionNumber
*/
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

@@ -0,0 +1,41 @@
<?php
/*
* 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 VersionNumber {
/**
* @var int
*/
private $value;
/**
* @param mixed $value
*/
public function __construct($value) {
if (is_numeric($value)) {
$this->value = $value;
}
}
/**
* @return bool
*/
public function isAny() {
return $this->value === null;
}
/**
* @return int
*/
public function getValue() {
return $this->value;
}
}

View File

@@ -0,0 +1,32 @@
<?php
/*
* 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;
abstract class AbstractVersionConstraint implements VersionConstraint {
/**
* @var string
*/
private $originalValue = '';
/**
* @param string $originalValue
*/
public function __construct($originalValue) {
$this->originalValue = $originalValue;
}
/**
* @return string
*/
public function asString() {
return $this->originalValue;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* 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 AndVersionConstraintGroup extends AbstractVersionConstraint {
/**
* @var VersionConstraint[]
*/
private $constraints = [];
/**
* @param string $originalValue
* @param VersionConstraint[] $constraints
*/
public function __construct($originalValue, array $constraints) {
parent::__construct($originalValue);
$this->constraints = $constraints;
}
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version) {
foreach ($this->constraints as $constraint) {
if (!$constraint->complies($version)) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* 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 AnyVersionConstraint implements VersionConstraint {
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version) {
return true;
}
/**
* @return string
*/
public function asString() {
return '*';
}
}

View File

@@ -0,0 +1,22 @@
<?php
/*
* 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 ExactVersionConstraint extends AbstractVersionConstraint {
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version) {
return $this->asString() == $version->getVersionString();
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* 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 GreaterThanOrEqualToVersionConstraint extends AbstractVersionConstraint {
/**
* @var Version
*/
private $minimalVersion;
/**
* @param string $originalValue
* @param Version $minimalVersion
*/
public function __construct($originalValue, Version $minimalVersion) {
parent::__construct($originalValue);
$this->minimalVersion = $minimalVersion;
}
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version) {
return $version->getVersionString() == $this->minimalVersion->getVersionString()
|| $version->isGreaterThan($this->minimalVersion);
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* 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 OrVersionConstraintGroup extends AbstractVersionConstraint {
/**
* @var VersionConstraint[]
*/
private $constraints = [];
/**
* @param string $originalValue
* @param VersionConstraint[] $constraints
*/
public function __construct($originalValue, array $constraints) {
parent::__construct($originalValue);
$this->constraints = $constraints;
}
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version) {
foreach ($this->constraints as $constraint) {
if ($constraint->complies($version)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* 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 SpecificMajorAndMinorVersionConstraint extends AbstractVersionConstraint {
/**
* @var int
*/
private $major = 0;
/**
* @var int
*/
private $minor = 0;
/**
* @param string $originalValue
* @param int $major
* @param int $minor
*/
public function __construct($originalValue, $major, $minor) {
parent::__construct($originalValue);
$this->major = $major;
$this->minor = $minor;
}
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version) {
if ($version->getMajor()->getValue() != $this->major) {
return false;
}
return $version->getMinor()->getValue() == $this->minor;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* 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 SpecificMajorVersionConstraint extends AbstractVersionConstraint {
/**
* @var int
*/
private $major = 0;
/**
* @param string $originalValue
* @param int $major
*/
public function __construct($originalValue, $major) {
parent::__construct($originalValue);
$this->major = $major;
}
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version) {
return $version->getMajor()->getValue() == $this->major;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* 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;
interface VersionConstraint {
/**
* @param Version $version
*
* @return bool
*/
public function complies(Version $version);
/**
* @return string
*/
public function asString();
}

View File

@@ -0,0 +1,14 @@
<?php
/*
* 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;
interface Exception {
}

View File

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

View File

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

View File

@@ -0,0 +1,14 @@
<?php
/*
* 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;
final class UnsupportedVersionConstraintException extends \RuntimeException implements Exception {
}

View File

@@ -0,0 +1,146 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\VersionConstraintParser
*/
class VersionConstraintParserTest extends TestCase {
/**
* @dataProvider versionStringProvider
*
* @param string $versionString
* @param VersionConstraint $expectedConstraint
*/
public function testReturnsExpectedConstraint($versionString, VersionConstraint $expectedConstraint) {
$parser = new VersionConstraintParser;
$this->assertEquals($expectedConstraint, $parser->parse($versionString));
}
/**
* @dataProvider unsupportedVersionStringProvider
*
* @param string $versionString
*/
public function testThrowsExceptionIfVersionStringIsNotSupported($versionString) {
$parser = new VersionConstraintParser;
$this->expectException(UnsupportedVersionConstraintException::class);
$parser->parse($versionString);
}
/**
* @return array
*/
public function versionStringProvider() {
return [
['1.0.2', new ExactVersionConstraint('1.0.2')],
[
'~4.6',
new AndVersionConstraintGroup(
'~4.6',
[
new GreaterThanOrEqualToVersionConstraint('~4.6', new Version('4.6')),
new SpecificMajorVersionConstraint('~4.6', 4)
]
)
],
[
'~4.6.2',
new AndVersionConstraintGroup(
'~4.6.2',
[
new GreaterThanOrEqualToVersionConstraint('~4.6.2', new Version('4.6.2')),
new SpecificMajorAndMinorVersionConstraint('~4.6.2', 4, 6)
]
)
],
[
'^2.6.1',
new AndVersionConstraintGroup(
'^2.6.1',
[
new GreaterThanOrEqualToVersionConstraint('^2.6.1', new Version('2.6.1')),
new SpecificMajorVersionConstraint('^2.6.1', 2)
]
)
],
['5.1.*', new SpecificMajorAndMinorVersionConstraint('5.1.*', 5, 1)],
['5.*', new SpecificMajorVersionConstraint('5.*', 5)],
['*', new AnyVersionConstraint()],
[
'1.0.2 || 1.0.5',
new OrVersionConstraintGroup(
'1.0.2 || 1.0.5',
[
new ExactVersionConstraint('1.0.2'),
new ExactVersionConstraint('1.0.5')
]
)
],
[
'^5.6 || ^7.0',
new OrVersionConstraintGroup(
'^5.6 || ^7.0',
[
new AndVersionConstraintGroup(
'^5.6', [
new GreaterThanOrEqualToVersionConstraint('^5.6', new Version('5.6')),
new SpecificMajorVersionConstraint('^5.6', 5)
]
),
new AndVersionConstraintGroup(
'^7.0', [
new GreaterThanOrEqualToVersionConstraint('^7.0', new Version('7.0')),
new SpecificMajorVersionConstraint('^7.0', 7)
]
)
]
)
],
['7.0.28-1', new ExactVersionConstraint('7.0.28-1')],
[
'^3.0.0-alpha1',
new AndVersionConstraintGroup(
'^3.0.0-alpha1',
[
new GreaterThanOrEqualToVersionConstraint('^3.0.0-alpha1', new Version('3.0.0-alpha1')),
new SpecificMajorVersionConstraint('^3.0.0-alpha1', 3)
]
)
],
[
'^3.0.0-alpha.1',
new AndVersionConstraintGroup(
'^3.0.0-alpha.1',
[
new GreaterThanOrEqualToVersionConstraint('^3.0.0-alpha.1', new Version('3.0.0-alpha.1')),
new SpecificMajorVersionConstraint('^3.0.0-alpha.1', 3)
]
)
]
];
}
public function unsupportedVersionStringProvider() {
return [
['foo'],
['+1.0.2'],
['>=2.0'],
['^5.6 || >= 7.0'],
['2.0 || foo']
];
}
}

View File

@@ -0,0 +1,25 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\AbstractVersionConstraint
*/
class AbstractVersionConstraintTest extends TestCase {
public function testAsString() {
/** @var AbstractVersionConstraint|\PHPUnit_Framework_MockObject_MockObject $constraint */
$constraint = $this->getMockForAbstractClass(AbstractVersionConstraint::class, ['foo']);
$this->assertSame('foo', $constraint->asString());
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\AndVersionConstraintGroup
*/
class AndVersionConstraintGroupTest extends TestCase {
public function testReturnsFalseIfOneConstraintReturnsFalse() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$group = new AndVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertFalse($group->complies(new Version('1.0.0')));
}
public function testReturnsTrueIfAllConstraintsReturnsTrue() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$group = new AndVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertTrue($group->complies(new Version('1.0.0')));
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\AnyVersionConstraint
*/
class AnyVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
[new Version('1.0.2')],
[new Version('4.8')],
[new Version('0.1.1-dev')]
];
}
/**
* @dataProvider versionProvider
*
* @param Version $version
*/
public function testReturnsTrue(Version $version) {
$constraint = new AnyVersionConstraint;
$this->assertTrue($constraint->complies($version));
}
public function testAsString() {
$this->assertSame('*', (new AnyVersionConstraint())->asString());
}
}

View File

@@ -0,0 +1,58 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\ExactVersionConstraint
*/
class ExactVersionConstraintTest extends TestCase {
public function compliantVersionProvider() {
return [
['1.0.2', new Version('1.0.2')],
['4.8.9', new Version('4.8.9')],
['4.8', new Version('4.8')],
];
}
public function nonCompliantVersionProvider() {
return [
['1.0.2', new Version('1.0.3')],
['4.8.9', new Version('4.7.9')],
['4.8', new Version('4.8.5')],
];
}
/**
* @dataProvider compliantVersionProvider
*
* @param string $constraintValue
* @param Version $version
*/
public function testReturnsTrueForCompliantVersion($constraintValue, Version $version) {
$constraint = new ExactVersionConstraint($constraintValue);
$this->assertTrue($constraint->complies($version));
}
/**
* @dataProvider nonCompliantVersionProvider
*
* @param string $constraintValue
* @param Version $version
*/
public function testReturnsFalseForNonCompliantVersion($constraintValue, Version $version) {
$constraint = new ExactVersionConstraint($constraintValue);
$this->assertFalse($constraint->complies($version));
}
}

View File

@@ -0,0 +1,47 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\GreaterThanOrEqualToVersionConstraint
*/
class GreaterThanOrEqualToVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
// compliant versions
[new Version('1.0.2'), new Version('1.0.2'), true],
[new Version('1.0.2'), new Version('1.0.3'), true],
[new Version('1.0.2'), new Version('1.1.1'), true],
[new Version('1.0.2'), new Version('2.0.0'), true],
[new Version('1.0.2'), new Version('1.0.3'), true],
// non-compliant versions
[new Version('1.0.2'), new Version('1.0.1'), false],
[new Version('1.9.8'), new Version('0.9.9'), false],
[new Version('2.3.1'), new Version('2.2.3'), false],
[new Version('3.0.2'), new Version('2.9.9'), false],
];
}
/**
* @dataProvider versionProvider
*
* @param Version $constraintVersion
* @param Version $version
* @param bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions(Version $constraintVersion, Version $version, $expectedResult) {
$constraint = new GreaterThanOrEqualToVersionConstraint('foo', $constraintVersion);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\OrVersionConstraintGroup
*/
class OrVersionConstraintGroupTest extends TestCase {
public function testReturnsTrueIfOneConstraintReturnsFalse() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertTrue($group->complies(new Version('1.0.0')));
}
public function testReturnsTrueIfAllConstraintsReturnsTrue() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertTrue($group->complies(new Version('1.0.0')));
}
public function testReturnsFalseIfAllConstraintsReturnsFalse() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertFalse($group->complies(new Version('1.0.0')));
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\PreReleaseSuffix
*/
class PreReleaseSuffixTest extends TestCase {
/**
* @dataProvider greaterThanProvider
*
* @param string $leftSuffixValue
* @param string $rightSuffixValue
* @param bool $expectedResult
*/
public function testGreaterThanReturnsExpectedResult(
$leftSuffixValue,
$rightSuffixValue,
$expectedResult
) {
$leftSuffix = new PreReleaseSuffix($leftSuffixValue);
$rightSuffix = new PreReleaseSuffix($rightSuffixValue);
$this->assertSame($expectedResult, $leftSuffix->isGreaterThan($rightSuffix));
}
public function greaterThanProvider() {
return [
['alpha1', 'alpha2', false],
['alpha2', 'alpha1', true],
['beta1', 'alpha3', true],
['b1', 'alpha3', true],
['b1', 'a3', true],
['dev1', 'alpha2', false],
['dev1', 'alpha2', false],
['alpha2', 'dev5', true],
['rc1', 'beta2', true],
['patch5', 'rc7', true],
['alpha1', 'alpha.2', false],
['alpha.3', 'alpha2', true],
['alpha.3', 'alpha.2', true],
];
}
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\SpecificMajorAndMinorVersionConstraint
*/
class SpecificMajorAndMinorVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
// compliant versions
[1, 0, new Version('1.0.2'), true],
[1, 0, new Version('1.0.3'), true],
[1, 1, new Version('1.1.1'), true],
// non-compliant versions
[2, 9, new Version('0.9.9'), false],
[3, 2, new Version('2.2.3'), false],
[2, 8, new Version('2.9.9'), false],
];
}
/**
* @dataProvider versionProvider
*
* @param int $major
* @param int $minor
* @param Version $version
* @param bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions($major, $minor, Version $version, $expectedResult) {
$constraint = new SpecificMajorAndMinorVersionConstraint('foo', $major, $minor);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\SpecificMajorVersionConstraint
*/
class SpecificMajorVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
// compliant versions
[1, new Version('1.0.2'), true],
[1, new Version('1.0.3'), true],
[1, new Version('1.1.1'), true],
// non-compliant versions
[2, new Version('0.9.9'), false],
[3, new Version('2.2.3'), false],
[3, new Version('2.9.9'), false],
];
}
/**
* @dataProvider versionProvider
*
* @param int $major
* @param Version $version
* @param bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions($major, Version $version, $expectedResult) {
$constraint = new SpecificMajorVersionConstraint('foo', $major);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}

View File

@@ -0,0 +1,113 @@
<?php
/*
* 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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\Version
*/
class VersionTest extends TestCase {
/**
* @dataProvider versionProvider
*
* @param string $versionString
* @param string $expectedMajor
* @param string $expectedMinor
* @param string $expectedPatch
* @param string $expectedPreReleaseValue
* @param int $expectedReleaseCount
*/
public function testParsesVersionNumbers(
$versionString,
$expectedMajor,
$expectedMinor,
$expectedPatch,
$expectedPreReleaseValue = '',
$expectedReleaseCount = 0
) {
$version = new Version($versionString);
$this->assertSame($expectedMajor, $version->getMajor()->getValue());
$this->assertSame($expectedMinor, $version->getMinor()->getValue());
$this->assertSame($expectedPatch, $version->getPatch()->getValue());
if ($expectedPreReleaseValue !== '') {
$this->assertSame($expectedPreReleaseValue, $version->getPreReleaseSuffix()->getValue());
}
if ($expectedReleaseCount !== 0) {
$this->assertSame($expectedReleaseCount, $version->getPreReleaseSuffix()->getNumber());
}
$this->assertSame($versionString, $version->getVersionString());
}
public function versionProvider() {
return [
['0.0.1', '0', '0', '1'],
['0.1.2', '0', '1', '2'],
['1.0.0-alpha', '1', '0', '0', 'alpha'],
['3.4.12-dev3', '3', '4', '12', 'dev', 3],
];
}
/**
* @dataProvider versionGreaterThanProvider
*
* @param Version $versionA
* @param Version $versionB
* @param bool $expectedResult
*/
public function testIsGreaterThan(Version $versionA, Version $versionB, $expectedResult) {
$this->assertSame($expectedResult, $versionA->isGreaterThan($versionB));
}
/**
* @return array
*/
public function versionGreaterThanProvider() {
return [
[new Version('1.0.0'), new Version('1.0.1'), false],
[new Version('1.0.1'), new Version('1.0.0'), true],
[new Version('1.1.0'), new Version('1.0.1'), true],
[new Version('1.1.0'), new Version('2.0.1'), false],
[new Version('1.1.0'), new Version('1.1.0'), false],
[new Version('2.5.8'), new Version('1.6.8'), true],
[new Version('2.5.8'), new Version('2.6.8'), false],
[new Version('2.5.8'), new Version('3.1.2'), false],
[new Version('3.0.0-alpha1'), new Version('3.0.0-alpha2'), false],
[new Version('3.0.0-alpha2'), new Version('3.0.0-alpha1'), true],
[new Version('3.0.0-alpha.1'), new Version('3.0.0'), false],
[new Version('3.0.0'), new Version('3.0.0-alpha.1'), true],
];
}
/**
* @dataProvider invalidVersionStringProvider
*
* @param string $versionString
*/
public function testThrowsExceptionIfVersionStringDoesNotFollowSemVer($versionString) {
$this->expectException(InvalidVersionException::class);
new Version($versionString);
}
/**
* @return array
*/
public function invalidVersionStringProvider() {
return [
['foo'],
['0.0.1-dev+ABC', '0', '0', '1', 'dev', 'ABC'],
['1.0.0-x.7.z.92', '1', '0', '0', 'x.7.z.92']
];
}
}