Repository: phar-io/version
Branch: master
Commit: 5eeb03f1ee82
Files: 45
Total size: 79.6 KB
Directory structure:
gitextract_esjl8x2z/
├── .gitattributes
├── .gitignore
├── .php_cs.dist
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.xml
├── composer.json
├── phive.xml
├── phpunit.xml
├── psalm.xml
├── src/
│ ├── BuildMetaData.php
│ ├── PreReleaseSuffix.php
│ ├── Version.php
│ ├── VersionConstraintParser.php
│ ├── VersionConstraintValue.php
│ ├── VersionNumber.php
│ ├── constraints/
│ │ ├── AbstractVersionConstraint.php
│ │ ├── AndVersionConstraintGroup.php
│ │ ├── AnyVersionConstraint.php
│ │ ├── ExactVersionConstraint.php
│ │ ├── GreaterThanOrEqualToVersionConstraint.php
│ │ ├── OrVersionConstraintGroup.php
│ │ ├── SpecificMajorAndMinorVersionConstraint.php
│ │ ├── SpecificMajorVersionConstraint.php
│ │ └── VersionConstraint.php
│ └── exceptions/
│ ├── Exception.php
│ ├── InvalidPreReleaseSuffixException.php
│ ├── InvalidVersionException.php
│ ├── NoBuildMetaDataException.php
│ ├── NoPreReleaseSuffixException.php
│ └── UnsupportedVersionConstraintException.php
└── tests/
├── Integration/
│ ├── CompliesTest.php
│ └── VersionConstraintParserTest.php
└── Unit/
├── AbstractVersionConstraintTest.php
├── AndVersionConstraintGroupTest.php
├── AnyVersionConstraintTest.php
├── BuildMetaDataTest.php
├── ExactVersionConstraintTest.php
├── GreaterThanOrEqualToVersionConstraintTest.php
├── OrVersionConstraintGroupTest.php
├── PreReleaseSuffixTest.php
├── SpecificMajorAndMinorVersionConstraintTest.php
├── SpecificMajorVersionConstraintTest.php
└── VersionTest.php
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist export-ignore
/.travis.yml export-ignore
/build.xml export-ignore
/phive.xml export-ignore
/phpunit.xml export-ignore
/psalm.xml export-ignore
================================================
FILE: .gitignore
================================================
/.github/
/.idea
/.php_cs.cache
/composer.lock
/tools
/vendor
build/coverage
.phpunit.result.cache
================================================
FILE: .php_cs.dist
================================================
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(
[
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'operators' => [
'=' => 'align',
'=>' => 'align',
],
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => false,
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'do',
'for',
'foreach',
'if',
'include',
'include_once',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
'yield',
],
],
'braces' => [
'allow_single_line_closure' => false,
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same',
'position_after_functions_and_oop_constructs' => 'same'
],
'cast_spaces' => ['space' => 'none'],
// This fixer removes the blank line at class start, no way to disable that, so we disable the fixer :(
//'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'date_time_immutable' => true,
'declare_equal_normalize' => ['space' => 'single'],
'declare_strict_types' => true,
'dir_constant' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => [
'closure_function_spacing' => 'one'
],
'header_comment' => false,
'indentation_type' => true,
'is_null' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'method_argument_space' => ['ensure_fully_multiline' => true],
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => true,
'native_function_casing' => true,
'native_function_invocation' => true,
'new_with_braces' => false,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_class_opening' => false,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'print'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => false,
'no_unneeded_curly_braces' => false,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public_static',
'property_protected_static',
'property_private_static',
'property_public',
'property_protected',
'property_private',
'method_public_static',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
'method_protected_static',
'method_private_static',
],
],
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => ['groups' => ['simple', 'meta']],
'phpdoc_types_order' => true,
'phpdoc_to_return_type' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'self_accessor' => false,
'semicolon_after_instruction' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simplified_null_return' => true,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => false,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],
'void_return' => true,
'whitespace_after_comma_in_array' => true,
'yoda_style' => false
]
)
->setFinder(
PhpCsFixer\Finder::create()
->files()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->notName('*.phpt')
);
================================================
FILE: CHANGELOG.md
================================================
# Changelog
All notable changes to phar-io/version are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [3.3.0] - 2024-??-??
### Fixed
- [#35](https://github.com/phar-io/version/issues/35): major version only not supported, e.g. ^6
## [3.2.1] - 2022-02-21
### Fixed
- Have ExactVersionConstraint honor build metadata (added in 3.2.0)
## [3.2.0] - 2022-02-21
### Added
- Build metadata is now supported and considered for equality checks only
## [3.1.1] - 2022-02-07
### Fixed
- [#28](https://github.com/phar-io/version/issues/28): `VersionConstraintParser` does not support logical OR represented by single pipe (|) (Thanks @llaville)
## [3.1.0] - 2021-02-23
### Changed
- Internal Refactoring
- More scalar types
### Added
- [#24](https://github.com/phar-io/version/issues/24): `Version::getOriginalString()` added (Thanks @addshore)
- Version constraints using the caret operator (`^`) now honor pre-1.0 releases, e.g. `^0.3` translates to `0.3.*`)
- Various integration tests for version constraint processing
### Fixed
- [#23](https://github.com/phar-io/version/pull/23): Tilde operator without patch level
## [3.0.4] - 14.12.2020
### Fixed
- [#22](https://github.com/phar-io/version/pull/22): make dev suffix rank works for uppercase too
## [3.0.3] - 30.11.2020
### Added
- Comparator method `Version::equals()` added
## [3.0.2] - 27.06.2020
This release now supports PHP 7.2+ and PHP ^8.0. No other changes included.
## [3.0.1] - 09.05.2020
__Potential BC Break Notice:__
`Version::getVersionString()` no longer returns `v` prefixes in case the "input"
string contained one. These are not part of the semver specs
(see https://semver.org/#is-v123-a-semantic-version) and get stripped out.
As of Version 3.1.0 `Version::getOriginalString()` can be used to still
retrieve it as given.
### Changed
- Internal Refactoring
- More scalar types
### Fixed
- Fixed Constraint processing Regression for ^1.2 and ~1.2
## [3.0.0] - 05.05.2020
### Changed
- Require PHP 7.2+
- All code now uses strict mode
- Scalar types have been added as needed
### Added
- The technically invalid format using 'v' prefix ("v1.2.3") is now properly supported
## [2.0.1] - 08.07.2018
### Fixed
- Versions without a pre-release suffix are now always considered greater
than versions with 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.
[3.3.0]: https://github.com/phar-io/version/compare/3.2.1...3.3.0
[3.2.1]: https://github.com/phar-io/version/compare/3.2.1...3.2.1
[3.2.0]: https://github.com/phar-io/version/compare/3.1.1...3.2.0
[3.1.1]: https://github.com/phar-io/version/compare/3.1.0...3.1.1
[3.1.0]: https://github.com/phar-io/version/compare/3.0.4...3.1.0
[3.0.4]: https://github.com/phar-io/version/compare/3.0.3...3.0.4
[3.0.3]: https://github.com/phar-io/version/compare/3.0.2...3.0.3
[3.0.2]: https://github.com/phar-io/version/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/phar-io/version/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/phar-io/version/compare/2.0.1...3.0.0
[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
================================================
FILE: LICENSE
================================================
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 the copyright holder 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.
================================================
FILE: README.md
================================================
# Version
Library for handling version information and constraints
[](https://github.com/phar-io/version/actions/workflows/ci.yml)
## 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
```
================================================
FILE: build.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project name="version" default="setup">
<property name="phive.bin" value="phive"/>
<target name="setup" depends="clean,install-tools,install-dependencies"/>
<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="install-tools" unless="tools-installed" depends="-tools-installed" description="Install tools with Phive">
<exec executable="${phive.bin}" taskname="phive" failonerror="true">
<arg value="install"/>
<arg value="--copy" />
<arg value="--trust-gpg-keys" />
<!-- php-cs-fixer ,psalm ,phpunit -->
<arg value="0xE82B2FB314E9906E,0x12CE0F1D262429A5,0x4AA394086372C20A" />
</exec>
</target>
<target name="install-dependencies" description="Install dependencies with Composer">
<exec executable="composer" taskname="composer">
<env key="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
<arg value="install"/>
<arg value="--no-ansi"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--optimize-autoloader"/>
</exec>
</target>
<target name="php-cs-fixer" depends="install-tools" description="Dry run php-cs-fixer">
<exec executable="${basedir}/tools/php-cs-fixer" failonerror="true">
<arg value="fix" />
<arg value="--dry-run" />
</exec>
</target>
<target name="psalm" depends="install-tools,install-dependencies" description="Run psalm">
<exec executable="${basedir}/tools/psalm" taskname="psalm-cache-clear">
<arg value="--config=psalm.xml" />
<arg value="--clear-cache" />
</exec>
<exec executable="${basedir}/tools/psalm" taskname="psalm" failonerror="true">
<arg value="--config=psalm.xml" />
<arg value="--show-info=true" />
<arg value="--stats" />
</exec>
</target>
<target name="psalm-baseline" depends="install-tools,install-dependencies" description="Run psalm">
<exec executable="${basedir}/tools/psalm" taskname="psalm-cache-clear">
<arg value="--config=psalm.xml" />
<arg value="--clear-cache" />
</exec>
<exec executable="${basedir}/tools/psalm" taskname="psalm-baseline">
<arg value="--config=psalm.xml" />
<arg value="--set-baseline=build/psalm-baseline.xml" />
<arg value="--show-info=false" />
</exec>
</target>
<target name="test" depends="install-tools,install-dependencies" description="Run tests">
<exec executable="${basedir}/tools/phpunit" taskname="phpunit"/>
</target>
<target name="test-with-code-coverage" depends="install-tools,install-dependencies" description="Run tests with code coverage">
<exec executable="${basedir}/tools/phpunit" taskname="phpunit">
<arg value="--coverage-clover build/logs/clover.xml" />
</exec>
</target>
<target name="-tools-installed">
<available file="${basedir}/tools/phpunit" property="tools-installed" type="file"/>
</target>
</project>
================================================
FILE: composer.json
================================================
{
"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": "^7.2 || ^8.0"
},
"autoload": {
"classmap": [
"src/"
]
}
}
================================================
FILE: phive.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^2.15.1" installed="2.19.3" location="./tools/php-cs-fixer" copy="true"/>
<phar name="psalm" version="^4.0" installed="4.21.0" location="./tools/psalm" copy="true"/>
<phar name="phpunit" version="^8.5.3" installed="8.5.23" location="./tools/phpunit" copy="true"/>
</phive>
================================================
FILE: phpunit.xml
================================================
<?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="vendor/autoload.php"
backupGlobals="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite name='tests'>
<directory suffix="Test.php">tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
================================================
FILE: psalm.xml
================================================
<?xml version="1.0"?>
<psalm xmlns="https://getpsalm.org/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor/" />
</ignoreFiles>
</projectFiles>
</psalm>
================================================
FILE: src/BuildMetaData.php
================================================
<?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();
}
}
================================================
FILE: src/PreReleaseSuffix.php
================================================
<?php declare(strict_types = 1);
namespace PharIo\Version;
class PreReleaseSuffix {
private const valueScoreMap = [
'dev' => 0,
'a' => 1,
'alpha' => 1,
'b' => 2,
'beta' => 2,
'rc' => 3,
'p' => 4,
'pl' => 4,
'patch' => 4,
];
/** @var string */
private $value;
/** @var int */
private $valueScore;
/** @var int */
private $number = 0;
/** @var string */
private $full;
/**
* @throws InvalidPreReleaseSuffixException
*/
public function __construct(string $value) {
$this->parseValue($value);
}
public function asString(): string {
return $this->full;
}
public function getValue(): string {
return $this->value;
}
public function getNumber(): ?int {
return $this->number;
}
public function isGreaterThan(PreReleaseSuffix $suffix): bool {
if ($this->valueScore > $suffix->valueScore) {
return true;
}
if ($this->valueScore < $suffix->valueScore) {
return false;
}
return $this->getNumber() > $suffix->getNumber();
}
private function mapValueToScore(string $value): int {
$value = \strtolower($value);
return self::valueScoreMap[$value];
}
private function parseValue(string $value): void {
$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));
}
$this->full = $matches[1];
$this->value = $matches[2];
if ($matches[3] !== '') {
$this->number = (int)$matches[3];
}
$this->valueScore = $this->mapValueToScore($matches[2]);
}
}
================================================
FILE: src/Version.php
================================================
<?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 Version {
/** @var string */
private $originalVersionString;
/** @var VersionNumber */
private $major;
/** @var VersionNumber */
private $minor;
/** @var VersionNumber */
private $patch;
/** @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');
}
return $this->preReleaseSuffix;
}
public function getOriginalString(): string {
return $this->originalVersionString;
}
public function getVersionString(): string {
$str = \sprintf(
'%d.%d.%d',
$this->getMajor()->getValue() ?? 0,
$this->getMinor()->getValue() ?? 0,
$this->getPatch()->getValue() ?? 0
);
if (!$this->hasPreReleaseSuffix()) {
return $str;
}
return $str . '-' . $this->getPreReleaseSuffix()->asString();
}
public function hasPreReleaseSuffix(): bool {
return $this->preReleaseSuffix !== null;
}
public function equals(Version $other): bool {
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 {
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());
}
public function getMajor(): VersionNumber {
return $this->major;
}
public function getMinor(): VersionNumber {
return $this->minor;
}
public function getPatch(): VersionNumber {
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
*
* @throws InvalidPreReleaseSuffixException
*/
private function parseVersion(array $matches): void {
$this->major = new VersionNumber((int)$matches['Major']);
$this->minor = isset($matches['Minor']) ? new VersionNumber((int)$matches['Minor']) : new VersionNumber(0);
$this->patch = isset($matches['Patch']) ? new VersionNumber((int)$matches['Patch']) : new VersionNumber(0);
if (isset($matches['PreReleaseSuffix']) && $matches['PreReleaseSuffix'] !== '') {
$this->preReleaseSuffix = new PreReleaseSuffix($matches['PreReleaseSuffix']);
}
if (isset($matches['BuildMetadata'])) {
$this->buildMetadata = new BuildMetaData($matches['BuildMetadata']);
}
}
/**
* @param string $version
*
* @throws InvalidVersionException
*/
private function ensureVersionStringIsValid($version): void {
$regex = '/^v?
(?P<Major>0|[1-9]\d*)
(\\.
(?P<Minor>0|[1-9]\d*)
)?
(\\.
(?P<Patch>0|[1-9]\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) {
throw new InvalidVersionException(
\sprintf("Version string '%s' does not follow SemVer semantics", $version)
);
}
$this->parseVersion($matches);
}
}
================================================
FILE: src/VersionConstraintParser.php
================================================
<?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 VersionConstraintParser {
/**
* @throws UnsupportedVersionConstraintException
*/
public function parse(string $value): VersionConstraint {
if (\strpos($value, '|') !== false) {
return $this->handleOrGroup($value);
}
if (!\preg_match('/^[\^~*]?v?[\d.*]+(?:-.*)?$/i', $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);
}
$constraint = new VersionConstraintValue($value);
if ($constraint->getMajor()->isAny()) {
return new AnyVersionConstraint();
}
if ($constraint->getMinor()->isAny()) {
return new SpecificMajorVersionConstraint(
$constraint->getVersionString(),
$constraint->getMajor()->getValue() ?? 0
);
}
if ($constraint->getPatch()->isAny()) {
return new SpecificMajorAndMinorVersionConstraint(
$constraint->getVersionString(),
$constraint->getMajor()->getValue() ?? 0,
$constraint->getMinor()->getValue() ?? 0
);
}
return new ExactVersionConstraint($constraint->getVersionString());
}
private function handleOrGroup(string $value): OrVersionConstraintGroup {
$constraints = [];
foreach (\preg_split('{\s*\|\|?\s*}', \trim($value)) as $groupSegment) {
$constraints[] = $this->parse(\trim($groupSegment));
}
return new OrVersionConstraintGroup($value, $constraints);
}
private function handleTildeOperator(string $value): AndVersionConstraintGroup {
$constraintValue = new VersionConstraintValue(\substr($value, 1));
if ($constraintValue->getPatch()->isAny()) {
return $this->handleCaretOperator($value);
}
$constraints = [
new GreaterThanOrEqualToVersionConstraint(
$value,
new Version(\substr($value, 1))
),
new SpecificMajorAndMinorVersionConstraint(
$value,
$constraintValue->getMajor()->getValue() ?? 0,
$constraintValue->getMinor()->getValue() ?? 0
)
];
return new AndVersionConstraintGroup($value, $constraints);
}
private function handleCaretOperator(string $value): AndVersionConstraintGroup {
$constraintValue = new VersionConstraintValue(\substr($value, 1));
$constraints = [
new GreaterThanOrEqualToVersionConstraint($value, new Version(\substr($value, 1)))
];
if ($constraintValue->getMajor()->getValue() === 0) {
$constraints[] = new SpecificMajorAndMinorVersionConstraint(
$value,
$constraintValue->getMajor()->getValue() ?? 0,
$constraintValue->getMinor()->getValue() ?? 0
);
} else {
$constraints[] = new SpecificMajorVersionConstraint(
$value,
$constraintValue->getMajor()->getValue() ?? 0
);
}
return new AndVersionConstraintGroup(
$value,
$constraints
);
}
}
================================================
FILE: src/VersionConstraintValue.php
================================================
<?php declare(strict_types = 1);
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 = '';
public function __construct(string $versionString) {
$this->versionString = $versionString;
$this->parseVersion($versionString);
}
public function getLabel(): string {
return $this->label;
}
public function getBuildMetaData(): string {
return $this->buildMetaData;
}
public function getVersionString(): string {
return $this->versionString;
}
public function getMajor(): VersionNumber {
return $this->major;
}
public function getMinor(): VersionNumber {
return $this->minor;
}
public function getPatch(): VersionNumber {
return $this->patch;
}
private function parseVersion(string $versionString): void {
$this->extractBuildMetaData($versionString);
$this->extractLabel($versionString);
$this->stripPotentialVPrefix($versionString);
$versionSegments = \explode('.', $versionString);
$this->major = new VersionNumber(\is_numeric($versionSegments[0]) ? (int)$versionSegments[0] : null);
$minorValue = isset($versionSegments[1]) && \is_numeric($versionSegments[1]) ? (int)$versionSegments[1] : null;
$patchValue = isset($versionSegments[2]) && \is_numeric($versionSegments[2]) ? (int)$versionSegments[2] : null;
$this->minor = new VersionNumber($minorValue);
$this->patch = new VersionNumber($patchValue);
}
private function extractBuildMetaData(string &$versionString): void {
if (\preg_match('/\+(.*)/', $versionString, $matches) === 1) {
$this->buildMetaData = $matches[1];
$versionString = \str_replace($matches[0], '', $versionString);
}
}
private function extractLabel(string &$versionString): void {
if (\preg_match('/-(.*)/', $versionString, $matches) === 1) {
$this->label = $matches[1];
$versionString = \str_replace($matches[0], '', $versionString);
}
}
private function stripPotentialVPrefix(string &$versionString): void {
if ($versionString[0] !== 'v') {
return;
}
$versionString = \substr($versionString, 1);
}
}
================================================
FILE: src/VersionNumber.php
================================================
<?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 VersionNumber {
/** @var ?int */
private $value;
public function __construct(?int $value) {
$this->value = $value;
}
public function isAny(): bool {
return $this->value === null;
}
public function getValue(): ?int {
return $this->value;
}
}
================================================
FILE: src/constraints/AbstractVersionConstraint.php
================================================
<?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;
abstract class AbstractVersionConstraint implements VersionConstraint {
/** @var string */
private $originalValue;
public function __construct(string $originalValue) {
$this->originalValue = $originalValue;
}
public function asString(): string {
return $this->originalValue;
}
}
================================================
FILE: src/constraints/AndVersionConstraintGroup.php
================================================
<?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 AndVersionConstraintGroup extends AbstractVersionConstraint {
/** @var VersionConstraint[] */
private $constraints = [];
/**
* @param VersionConstraint[] $constraints
*/
public function __construct(string $originalValue, array $constraints) {
parent::__construct($originalValue);
$this->constraints = $constraints;
}
public function complies(Version $version): bool {
foreach ($this->constraints as $constraint) {
if (!$constraint->complies($version)) {
return false;
}
}
return true;
}
}
================================================
FILE: src/constraints/AnyVersionConstraint.php
================================================
<?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 AnyVersionConstraint implements VersionConstraint {
public function complies(Version $version): bool {
return true;
}
public function asString(): string {
return '*';
}
}
================================================
FILE: src/constraints/ExactVersionConstraint.php
================================================
<?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 ExactVersionConstraint extends AbstractVersionConstraint {
public function complies(Version $version): bool {
$other = $version->getVersionString();
if ($version->hasBuildMetaData()) {
$other .= '+' . $version->getBuildMetaData()->asString();
}
return $this->asString() === $other;
}
}
================================================
FILE: src/constraints/GreaterThanOrEqualToVersionConstraint.php
================================================
<?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 GreaterThanOrEqualToVersionConstraint extends AbstractVersionConstraint {
/** @var Version */
private $minimalVersion;
public function __construct(string $originalValue, Version $minimalVersion) {
parent::__construct($originalValue);
$this->minimalVersion = $minimalVersion;
}
public function complies(Version $version): bool {
return $version->getVersionString() === $this->minimalVersion->getVersionString()
|| $version->isGreaterThan($this->minimalVersion);
}
}
================================================
FILE: src/constraints/OrVersionConstraintGroup.php
================================================
<?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 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;
}
public function complies(Version $version): bool {
foreach ($this->constraints as $constraint) {
if ($constraint->complies($version)) {
return true;
}
}
return false;
}
}
================================================
FILE: src/constraints/SpecificMajorAndMinorVersionConstraint.php
================================================
<?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 SpecificMajorAndMinorVersionConstraint extends AbstractVersionConstraint {
/** @var int */
private $major;
/** @var int */
private $minor;
public function __construct(string $originalValue, int $major, int $minor) {
parent::__construct($originalValue);
$this->major = $major;
$this->minor = $minor;
}
public function complies(Version $version): bool {
if ($version->getMajor()->getValue() !== $this->major) {
return false;
}
return $version->getMinor()->getValue() === $this->minor;
}
}
================================================
FILE: src/constraints/SpecificMajorVersionConstraint.php
================================================
<?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 SpecificMajorVersionConstraint extends AbstractVersionConstraint {
/** @var int */
private $major;
public function __construct(string $originalValue, int $major) {
parent::__construct($originalValue);
$this->major = $major;
}
public function complies(Version $version): bool {
return $version->getMajor()->getValue() === $this->major;
}
}
================================================
FILE: src/constraints/VersionConstraint.php
================================================
<?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;
interface VersionConstraint {
public function complies(Version $version): bool;
public function asString(): string;
}
================================================
FILE: src/exceptions/Exception.php
================================================
<?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;
use Throwable;
interface Exception extends Throwable {
}
================================================
FILE: src/exceptions/InvalidPreReleaseSuffixException.php
================================================
<?php declare(strict_types = 1);
namespace PharIo\Version;
class InvalidPreReleaseSuffixException extends \Exception implements Exception {
}
================================================
FILE: src/exceptions/InvalidVersionException.php
================================================
<?php declare(strict_types = 1);
namespace PharIo\Version;
class InvalidVersionException extends \InvalidArgumentException implements Exception {
}
================================================
FILE: src/exceptions/NoBuildMetaDataException.php
================================================
<?php declare(strict_types = 1);
namespace PharIo\Version;
class NoBuildMetaDataException extends \Exception implements Exception {
}
================================================
FILE: src/exceptions/NoPreReleaseSuffixException.php
================================================
<?php declare(strict_types = 1);
namespace PharIo\Version;
class NoPreReleaseSuffixException extends \Exception implements Exception {
}
================================================
FILE: src/exceptions/UnsupportedVersionConstraintException.php
================================================
<?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;
final class UnsupportedVersionConstraintException extends \RuntimeException implements Exception {
}
================================================
FILE: tests/Integration/CompliesTest.php
================================================
<?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;
use PHPUnit\Framework\TestCase;
class CompliesTest extends TestCase {
/**
* @dataProvider complyingProvider
*/
public function testCompliesWhenExcepted(string $constraint, string $version): void {
$this->assertTrue(
(new VersionConstraintParser())->parse($constraint)->complies(new Version($version))
);
}
/**
* @dataProvider notComplyingProvider
*/
public function testNotCompliesWhenExcepted(string $constraint, string $version): void {
$this->assertFalse(
(new VersionConstraintParser())->parse($constraint)->complies(new Version($version))
);
}
public function complyingProvider(): array {
return [
'1.0.0' => ['1.0.0', '1.0.0'],
'~7.0.0' => ['~7.0.0', '7.0.1'],
'~7.0' => ['~7.0', '7.0.1'],
'~8.0' => ['~8.0', '8.2.3'],
'^7.0.0' => ['^7.0.0', '7.0.1'],
'^7.0' => ['^7.0', '7.0.1'],
'^8.0' => ['^8.0', '8.2.3'],
'^7.2 || ^8.0' => ['^7.2 || ^8.0', '7.4.12'],
'^7.3 || ^8.0' => ['^7.3 || ^8.0', '8.0.3'],
'^7.4 || ^8.0' => ['^7.3 || ^8.0', '8.1.3'],
'5.1.*' => ['5.1.*', '5.1.3'],
'^0.3' => ['^0.3', '0.3.1']
];
}
public function notComplyingProvider(): array {
return [
'1.0.0' => ['1.0.0', '1.0.1'],
'~4.6' => ['~4.6', '4.5.3'],
'~8.0.0' => ['~8.0.0', '8.1.0'],
'5.1.*' => ['5.1.*', '5.2.1'],
'5.2.*' => ['5.2.*', '5.1.9'],
'^0.3' => ['^0.3', '0.4.1']
];
}
}
================================================
FILE: tests/Integration/VersionConstraintParserTest.php
================================================
<?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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\VersionConstraintParser
*/
class VersionConstraintParserTest extends TestCase {
/**
* @dataProvider versionStringProvider
*
* @param string $versionString
*/
public function testReturnsExpectedConstraint($versionString, VersionConstraint $expectedConstraint): void {
$parser = new VersionConstraintParser;
$this->assertEquals($expectedConstraint, $parser->parse($versionString));
}
/**
* @dataProvider unsupportedVersionStringProvider
*
* @param string $versionString
*/
public function testThrowsExceptionIfVersionStringIsNotSupported($versionString): void {
$parser = new VersionConstraintParser;
$this->expectException(UnsupportedVersionConstraintException::class);
$parser->parse($versionString);
}
public function versionStringProvider(): array {
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)
]
)
]
)
],
[
'^5.3.2 | ^7.0 || ^8.0',
new OrVersionConstraintGroup(
'^5.3.2 | ^7.0 || ^8.0',
[
new AndVersionConstraintGroup(
'^5.3.2',
[
new GreaterThanOrEqualToVersionConstraint('^5.3.2', new Version('5.3.2')),
new SpecificMajorVersionConstraint('^5.3.2', 5)
]
),
new AndVersionConstraintGroup(
'^7.0',
[
new GreaterThanOrEqualToVersionConstraint('^7.0', new Version('7.0')),
new SpecificMajorVersionConstraint('^7.0', 7)
]
),
new AndVersionConstraintGroup(
'^8.0',
[
new GreaterThanOrEqualToVersionConstraint('^8.0', new Version('8.0')),
new SpecificMajorVersionConstraint('^8.0', 8)
]
)
]
)
],
['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)
]
)
],
[
'^1.0',
new AndVersionConstraintGroup(
'^1.0',
[
new GreaterThanOrEqualToVersionConstraint('^1.0', new Version('1.0')),
new SpecificMajorVersionConstraint('^1.0', 1)
]
)
],
[
'^1',
new AndVersionConstraintGroup(
'^1',
[
new GreaterThanOrEqualToVersionConstraint('^1', new Version('1')),
new SpecificMajorVersionConstraint('^1', 1)
]
)
]
];
}
public function unsupportedVersionStringProvider() {
return [
['foo'],
['+1.0.2'],
['>=2.0'],
['^5.6 || >= 7.0'],
['2.0 || foo']
];
}
}
================================================
FILE: tests/Unit/AbstractVersionConstraintTest.php
================================================
<?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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\AbstractVersionConstraint
*/
class AbstractVersionConstraintTest extends TestCase {
public function testAsString(): void {
/** @var AbstractVersionConstraint|\PHPUnit_Framework_MockObject_MockObject $constraint */
$constraint = $this->getMockForAbstractClass(AbstractVersionConstraint::class, ['foo']);
$this->assertSame('foo', $constraint->asString());
}
}
================================================
FILE: tests/Unit/AndVersionConstraintGroupTest.php
================================================
<?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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\AndVersionConstraintGroup
*/
class AndVersionConstraintGroupTest extends TestCase {
public function testReturnsFalseIfOneConstraintReturnsFalse(): void {
$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(): void {
$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')));
}
}
================================================
FILE: tests/Unit/AnyVersionConstraintTest.php
================================================
<?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;
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
*/
public function testReturnsTrue(Version $version): void {
$constraint = new AnyVersionConstraint;
$this->assertTrue($constraint->complies($version));
}
public function testAsString(): void {
$this->assertSame('*', (new AnyVersionConstraint())->asString());
}
}
================================================
FILE: tests/Unit/BuildMetaDataTest.php
================================================
<?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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\BuildMetaData
*/
class BuildMetaDataTest extends TestCase {
public function testCanBeCreated(): void {
$this->assertInstanceOf(BuildMetaData::class, new BuildMetaData('some'));
}
public function testSetValueCanBeRetrieved(): void {
$this->assertSame('some', (new BuildMetaData('some'))->asString());
}
public function testTwoIdenticalMetadataStringsAreConsideredEqual(): void {
$a = new BuildMetaData('foo');
$b = new BuildMetaData('foo');
$this->assertTrue($a->equals($b));
}
public function testTwoNonIdenticalMetadataStringsAreNotConsideredEqual(): void {
$a = new BuildMetaData('abc');
$b = new BuildMetaData('def');
$this->assertFalse($a->equals($b));
}
}
================================================
FILE: tests/Unit/ExactVersionConstraintTest.php
================================================
<?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;
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.0', new Version('4.8')],
['1.2.3-dev', new Version('1.2.3-dev')],
['1.2.3+abc', new Version('1.2.3+abc')]
];
}
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')],
['1.2.3+abc', new Version('1.2.3+def')]
];
}
/**
* @dataProvider compliantVersionProvider
*
* @param string $constraintValue
*/
public function testReturnsTrueForCompliantVersion($constraintValue, Version $version): void {
$constraint = new ExactVersionConstraint($constraintValue);
$this->assertTrue($constraint->complies($version));
}
/**
* @dataProvider nonCompliantVersionProvider
*
* @param string $constraintValue
*/
public function testReturnsFalseForNonCompliantVersion($constraintValue, Version $version): void {
$constraint = new ExactVersionConstraint($constraintValue);
$this->assertFalse($constraint->complies($version));
}
}
================================================
FILE: tests/Unit/GreaterThanOrEqualToVersionConstraintTest.php
================================================
<?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;
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 bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions(Version $constraintVersion, Version $version, $expectedResult): void {
$constraint = new GreaterThanOrEqualToVersionConstraint('foo', $constraintVersion);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}
================================================
FILE: tests/Unit/OrVersionConstraintGroupTest.php
================================================
<?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;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\OrVersionConstraintGroup
*/
class OrVersionConstraintGroupTest extends TestCase {
public function testReturnsTrueIfOneConstraintReturnsFalse(): void {
$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(): void {
$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(): void {
$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')));
}
}
================================================
FILE: tests/Unit/PreReleaseSuffixTest.php
================================================
<?php declare(strict_types = 1);
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\PreReleaseSuffix
*/
class PreReleaseSuffixTest extends TestCase {
/**
* @dataProvider greaterThanProvider
*/
public function testGreaterThanReturnsExpectedResult(
string $leftSuffixValue,
string $rightSuffixValue,
bool $expectedResult
): void {
$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],
];
}
/**
* @dataProvider suffixProvider
*/
public function testParsedValue(string $suffix): void {
$prs = new PreReleaseSuffix($suffix);
$this->assertEquals($suffix, $prs->asString());
}
public function suffixProvider() {
return [
['alpha1'],
['beta1'],
['b1'],
['dev1'],
['rc1'],
['patch5'],
['alpha.1'],
['beta.1'],
['b.1'],
['dev.1'],
['rc.1'],
['patch.5']
];
}
public function testLabelCanBeRetrieved(): void {
$this->assertSame('rc', (new PreReleaseSuffix('rc1'))->getValue());
}
public function testCreatingWithUnsupportedLabelTypeThrowsException(): void {
$this->expectException(InvalidPreReleaseSuffixException::class);
(new PreReleaseSuffix('foo'));
}
}
================================================
FILE: tests/Unit/SpecificMajorAndMinorVersionConstraintTest.php
================================================
<?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;
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 bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions($major, $minor, Version $version, $expectedResult): void {
$constraint = new SpecificMajorAndMinorVersionConstraint('foo', $major, $minor);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}
================================================
FILE: tests/Unit/SpecificMajorVersionConstraintTest.php
================================================
<?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;
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 bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions($major, Version $version, $expectedResult): void {
$constraint = new SpecificMajorVersionConstraint('foo', $major);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}
================================================
FILE: tests/Unit/VersionTest.php
================================================
<?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;
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
* @param string $metaData
*/
public function testParsesVersionNumbers(
$versionString,
$expectedMajor,
$expectedMinor,
$expectedPatch,
$expectedPreReleaseValue = '',
$expectedReleaseCount = 0,
$metaData = ''
): void {
$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());
}
if ($metaData !== '') {
$this->assertSame($metaData, $version->getBuildMetaData()->asString());
}
}
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],
['1.2.3-beta.2', 1, 2, 3, 'beta', 2],
['v1.2.3-rc', 1, 2, 3, 'rc'],
['v1.2.3-rc1', 1, 2, 3, 'rc', 1],
['0.0.1-dev+ABC', 0, 0, 1, 'dev', 0, 'ABC'],
['0.0.1+git-15a90844ad40f127afd244c0cad228de2a80052a', 0, 0, 1, '', 0, 'git-15a90844ad40f127afd244c0cad228de2a80052a']
];
}
/**
* @dataProvider versionStringProvider
*/
public function testOrigionalStringReturnsExceptedVersionString(string $input): void {
$this->assertEquals(
(new Version($input))->getOriginalString(),
$input
);
}
/**
* @dataProvider versionStringProvider
*/
public function testAsStringReturnsExceptedVersionString(string $input, string $excepted): void {
$this->assertEquals(
(new Version($input))->getVersionString(),
$excepted
);
}
/**
* @dataProvider versionGreaterThanProvider
*
* @param bool $expectedResult
*/
public function testIsGreaterThan(Version $versionA, Version $versionB, $expectedResult): void {
$this->assertSame($expectedResult, $versionA->isGreaterThan($versionB));
}
public function versionGreaterThanProvider(): array {
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): void {
$this->expectException(InvalidVersionException::class);
new Version($versionString);
}
public function invalidVersionStringProvider(): array {
return [
['foo'],
['1.2.3.4'],
['1.0.0-x.7.z.92']
];
}
public function versionStringProvider() {
return [
['0.0.1', '0.0.1'],
['0.1.0', '0.1.0'],
['1.0.0-alpha', '1.0.0-alpha'],
['3.4.12-dev3', '3.4.12-dev3'],
['1.2.3-beta.2', '1.2.3-beta.2'],
['v0.0.1', '0.0.1'],
['v0.1.0', '0.1.0'],
['v1.0.0-alpha', '1.0.0-alpha'],
['v3.4.12-dev3', '3.4.12-dev3'],
['v1.2.3-beta.2', '1.2.3-beta.2'],
['0.1', '0.1.0'],
['v0.1', '0.1.0'],
['1', '1.0.0']
];
}
public function testIdenticalVersionsAreConsideredEqual(): void {
$a = new Version('1.0.0-rc1');
$b = new Version('1.0.0-rc1');
$this->assertTrue($a->equals($b));
}
public function testNonIdenticalVersionsAreNotConsideredEqual(): void {
$a = new Version('1.0.0-rc1');
$b = new Version('1.0.0-rc2');
$this->assertFalse($a->equals($b));
}
public function testIdenticalVersionsWithBuildMetaDataAreConsideredEqual(): void {
$a = new Version('1.0.0-rc1+abc');
$b = new Version('1.0.0-rc1+abc');
$this->assertTrue($a->equals($b));
}
public function testIdenticalVersionsWithOnlyOneHavingBuildMetaDataAreNotConsideredEqual(): void {
$a = new Version('1.0.0-rc1+abc');
$b = new Version('1.0.0-rc1');
$this->assertFalse($a->equals($b));
}
public function testIdenticalVersionsWithDifferingBuildMetaDataAreNotConsideredEqual(): void {
$a = new Version('1.0.0-rc1+abc');
$b = new Version('1.0.0-rc1+def');
$this->assertFalse($a->equals($b));
}
public function testGetPreReleaseSuffixThrowsExceptionWhenNoneIsSet(): void {
$this->expectException(NoPreReleaseSuffixException::class);
(new Version('1.2.3'))->getPreReleaseSuffix();
}
public function testGetBuildMetadataThrowsExceptionWhenNoneIsSet(): void {
$this->expectException(NoBuildMetaDataException::class);
(new Version('1.2.3'))->getBuildMetaData();
}
public function testHasBuildMetadataReturnsFalseWhenNoneIsSet(): void {
$this->assertFalse((new Version('1.2.3'))->hasBuildMetaData());
}
public function testBuildMetadataCanBeRetreived(): void {
$this->assertSame('test', (new Version('1.2.3+test'))->getBuildMetaData()->asString());
}
}
gitextract_esjl8x2z/
├── .gitattributes
├── .gitignore
├── .php_cs.dist
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.xml
├── composer.json
├── phive.xml
├── phpunit.xml
├── psalm.xml
├── src/
│ ├── BuildMetaData.php
│ ├── PreReleaseSuffix.php
│ ├── Version.php
│ ├── VersionConstraintParser.php
│ ├── VersionConstraintValue.php
│ ├── VersionNumber.php
│ ├── constraints/
│ │ ├── AbstractVersionConstraint.php
│ │ ├── AndVersionConstraintGroup.php
│ │ ├── AnyVersionConstraint.php
│ │ ├── ExactVersionConstraint.php
│ │ ├── GreaterThanOrEqualToVersionConstraint.php
│ │ ├── OrVersionConstraintGroup.php
│ │ ├── SpecificMajorAndMinorVersionConstraint.php
│ │ ├── SpecificMajorVersionConstraint.php
│ │ └── VersionConstraint.php
│ └── exceptions/
│ ├── Exception.php
│ ├── InvalidPreReleaseSuffixException.php
│ ├── InvalidVersionException.php
│ ├── NoBuildMetaDataException.php
│ ├── NoPreReleaseSuffixException.php
│ └── UnsupportedVersionConstraintException.php
└── tests/
├── Integration/
│ ├── CompliesTest.php
│ └── VersionConstraintParserTest.php
└── Unit/
├── AbstractVersionConstraintTest.php
├── AndVersionConstraintGroupTest.php
├── AnyVersionConstraintTest.php
├── BuildMetaDataTest.php
├── ExactVersionConstraintTest.php
├── GreaterThanOrEqualToVersionConstraintTest.php
├── OrVersionConstraintGroupTest.php
├── PreReleaseSuffixTest.php
├── SpecificMajorAndMinorVersionConstraintTest.php
├── SpecificMajorVersionConstraintTest.php
└── VersionTest.php
SYMBOL INDEX (148 symbols across 34 files)
FILE: src/BuildMetaData.php
class BuildMetaData (line 12) | class BuildMetaData {
method __construct (line 17) | public function __construct(string $value) {
method asString (line 21) | public function asString(): string {
method equals (line 25) | public function equals(BuildMetaData $other): bool {
FILE: src/PreReleaseSuffix.php
class PreReleaseSuffix (line 4) | class PreReleaseSuffix {
method __construct (line 32) | public function __construct(string $value) {
method asString (line 36) | public function asString(): string {
method getValue (line 40) | public function getValue(): string {
method getNumber (line 44) | public function getNumber(): ?int {
method isGreaterThan (line 48) | public function isGreaterThan(PreReleaseSuffix $suffix): bool {
method mapValueToScore (line 60) | private function mapValueToScore(string $value): int {
method parseValue (line 66) | private function parseValue(string $value): void {
FILE: src/Version.php
class Version (line 12) | class Version {
method __construct (line 31) | public function __construct(string $versionString) {
method getPreReleaseSuffix (line 39) | public function getPreReleaseSuffix(): PreReleaseSuffix {
method getOriginalString (line 47) | public function getOriginalString(): string {
method getVersionString (line 51) | public function getVersionString(): string {
method hasPreReleaseSuffix (line 66) | public function hasPreReleaseSuffix(): bool {
method equals (line 70) | public function equals(Version $other): bool {
method isGreaterThan (line 87) | public function isGreaterThan(Version $version): bool {
method getMajor (line 127) | public function getMajor(): VersionNumber {
method getMinor (line 131) | public function getMinor(): VersionNumber {
method getPatch (line 135) | public function getPatch(): VersionNumber {
method hasBuildMetaData (line 143) | public function hasBuildMetaData(): bool {
method getBuildMetaData (line 150) | public function getBuildMetaData(): BuildMetaData {
method parseVersion (line 163) | private function parseVersion(array $matches): void {
method ensureVersionStringIsValid (line 182) | private function ensureVersionStringIsValid($version): void {
FILE: src/VersionConstraintParser.php
class VersionConstraintParser (line 12) | class VersionConstraintParser {
method parse (line 16) | public function parse(string $value): VersionConstraint {
method handleOrGroup (line 58) | private function handleOrGroup(string $value): OrVersionConstraintGroup {
method handleTildeOperator (line 68) | private function handleTildeOperator(string $value): AndVersionConstra...
method handleCaretOperator (line 90) | private function handleCaretOperator(string $value): AndVersionConstra...
FILE: src/VersionConstraintValue.php
class VersionConstraintValue (line 4) | class VersionConstraintValue {
method __construct (line 23) | public function __construct(string $versionString) {
method getLabel (line 29) | public function getLabel(): string {
method getBuildMetaData (line 33) | public function getBuildMetaData(): string {
method getVersionString (line 37) | public function getVersionString(): string {
method getMajor (line 41) | public function getMajor(): VersionNumber {
method getMinor (line 45) | public function getMinor(): VersionNumber {
method getPatch (line 49) | public function getPatch(): VersionNumber {
method parseVersion (line 53) | private function parseVersion(string $versionString): void {
method extractBuildMetaData (line 68) | private function extractBuildMetaData(string &$versionString): void {
method extractLabel (line 75) | private function extractLabel(string &$versionString): void {
method stripPotentialVPrefix (line 82) | private function stripPotentialVPrefix(string &$versionString): void {
FILE: src/VersionNumber.php
class VersionNumber (line 12) | class VersionNumber {
method __construct (line 17) | public function __construct(?int $value) {
method isAny (line 21) | public function isAny(): bool {
method getValue (line 25) | public function getValue(): ?int {
FILE: src/constraints/AbstractVersionConstraint.php
class AbstractVersionConstraint (line 12) | abstract class AbstractVersionConstraint implements VersionConstraint {
method __construct (line 16) | public function __construct(string $originalValue) {
method asString (line 20) | public function asString(): string {
FILE: src/constraints/AndVersionConstraintGroup.php
class AndVersionConstraintGroup (line 12) | class AndVersionConstraintGroup extends AbstractVersionConstraint {
method __construct (line 19) | public function __construct(string $originalValue, array $constraints) {
method complies (line 25) | public function complies(Version $version): bool {
FILE: src/constraints/AnyVersionConstraint.php
class AnyVersionConstraint (line 12) | class AnyVersionConstraint implements VersionConstraint {
method complies (line 13) | public function complies(Version $version): bool {
method asString (line 17) | public function asString(): string {
FILE: src/constraints/ExactVersionConstraint.php
class ExactVersionConstraint (line 12) | class ExactVersionConstraint extends AbstractVersionConstraint {
method complies (line 13) | public function complies(Version $version): bool {
FILE: src/constraints/GreaterThanOrEqualToVersionConstraint.php
class GreaterThanOrEqualToVersionConstraint (line 12) | class GreaterThanOrEqualToVersionConstraint extends AbstractVersionConst...
method __construct (line 16) | public function __construct(string $originalValue, Version $minimalVer...
method complies (line 22) | public function complies(Version $version): bool {
FILE: src/constraints/OrVersionConstraintGroup.php
class OrVersionConstraintGroup (line 12) | class OrVersionConstraintGroup extends AbstractVersionConstraint {
method __construct (line 20) | public function __construct($originalValue, array $constraints) {
method complies (line 26) | public function complies(Version $version): bool {
FILE: src/constraints/SpecificMajorAndMinorVersionConstraint.php
class SpecificMajorAndMinorVersionConstraint (line 12) | class SpecificMajorAndMinorVersionConstraint extends AbstractVersionCons...
method __construct (line 19) | public function __construct(string $originalValue, int $major, int $mi...
method complies (line 26) | public function complies(Version $version): bool {
FILE: src/constraints/SpecificMajorVersionConstraint.php
class SpecificMajorVersionConstraint (line 12) | class SpecificMajorVersionConstraint extends AbstractVersionConstraint {
method __construct (line 16) | public function __construct(string $originalValue, int $major) {
method complies (line 22) | public function complies(Version $version): bool {
FILE: src/constraints/VersionConstraint.php
type VersionConstraint (line 12) | interface VersionConstraint {
method complies (line 13) | public function complies(Version $version): bool;
method asString (line 15) | public function asString(): string;
FILE: src/exceptions/Exception.php
type Exception (line 14) | interface Exception extends Throwable {
FILE: src/exceptions/InvalidPreReleaseSuffixException.php
class InvalidPreReleaseSuffixException (line 4) | class InvalidPreReleaseSuffixException extends \Exception implements Exc...
FILE: src/exceptions/InvalidVersionException.php
class InvalidVersionException (line 4) | class InvalidVersionException extends \InvalidArgumentException implemen...
FILE: src/exceptions/NoBuildMetaDataException.php
class NoBuildMetaDataException (line 4) | class NoBuildMetaDataException extends \Exception implements Exception {
FILE: src/exceptions/NoPreReleaseSuffixException.php
class NoPreReleaseSuffixException (line 4) | class NoPreReleaseSuffixException extends \Exception implements Exception {
FILE: src/exceptions/UnsupportedVersionConstraintException.php
class UnsupportedVersionConstraintException (line 12) | final class UnsupportedVersionConstraintException extends \RuntimeExcept...
FILE: tests/Integration/CompliesTest.php
class CompliesTest (line 14) | class CompliesTest extends TestCase {
method testCompliesWhenExcepted (line 19) | public function testCompliesWhenExcepted(string $constraint, string $v...
method testNotCompliesWhenExcepted (line 28) | public function testNotCompliesWhenExcepted(string $constraint, string...
method complyingProvider (line 34) | public function complyingProvider(): array {
method notComplyingProvider (line 55) | public function notComplyingProvider(): array {
FILE: tests/Integration/VersionConstraintParserTest.php
class VersionConstraintParserTest (line 17) | class VersionConstraintParserTest extends TestCase {
method testReturnsExpectedConstraint (line 23) | public function testReturnsExpectedConstraint($versionString, VersionC...
method testThrowsExceptionIfVersionStringIsNotSupported (line 34) | public function testThrowsExceptionIfVersionStringIsNotSupported($vers...
method versionStringProvider (line 42) | public function versionStringProvider(): array {
method unsupportedVersionStringProvider (line 183) | public function unsupportedVersionStringProvider() {
FILE: tests/Unit/AbstractVersionConstraintTest.php
class AbstractVersionConstraintTest (line 17) | class AbstractVersionConstraintTest extends TestCase {
method testAsString (line 18) | public function testAsString(): void {
FILE: tests/Unit/AndVersionConstraintGroupTest.php
class AndVersionConstraintGroupTest (line 17) | class AndVersionConstraintGroupTest extends TestCase {
method testReturnsFalseIfOneConstraintReturnsFalse (line 18) | public function testReturnsFalseIfOneConstraintReturnsFalse(): void {
method testReturnsTrueIfAllConstraintsReturnsTrue (line 35) | public function testReturnsTrueIfAllConstraintsReturnsTrue(): void {
FILE: tests/Unit/AnyVersionConstraintTest.php
class AnyVersionConstraintTest (line 17) | class AnyVersionConstraintTest extends TestCase {
method versionProvider (line 18) | public function versionProvider() {
method testReturnsTrue (line 29) | public function testReturnsTrue(Version $version): void {
method testAsString (line 35) | public function testAsString(): void {
FILE: tests/Unit/BuildMetaDataTest.php
class BuildMetaDataTest (line 17) | class BuildMetaDataTest extends TestCase {
method testCanBeCreated (line 18) | public function testCanBeCreated(): void {
method testSetValueCanBeRetrieved (line 22) | public function testSetValueCanBeRetrieved(): void {
method testTwoIdenticalMetadataStringsAreConsideredEqual (line 26) | public function testTwoIdenticalMetadataStringsAreConsideredEqual(): v...
method testTwoNonIdenticalMetadataStringsAreNotConsideredEqual (line 33) | public function testTwoNonIdenticalMetadataStringsAreNotConsideredEqua...
FILE: tests/Unit/ExactVersionConstraintTest.php
class ExactVersionConstraintTest (line 17) | class ExactVersionConstraintTest extends TestCase {
method compliantVersionProvider (line 18) | public function compliantVersionProvider() {
method nonCompliantVersionProvider (line 28) | public function nonCompliantVersionProvider() {
method testReturnsTrueForCompliantVersion (line 42) | public function testReturnsTrueForCompliantVersion($constraintValue, V...
method testReturnsFalseForNonCompliantVersion (line 53) | public function testReturnsFalseForNonCompliantVersion($constraintValu...
FILE: tests/Unit/GreaterThanOrEqualToVersionConstraintTest.php
class GreaterThanOrEqualToVersionConstraintTest (line 17) | class GreaterThanOrEqualToVersionConstraintTest extends TestCase {
method versionProvider (line 18) | public function versionProvider() {
method testReturnsTrueForCompliantVersions (line 39) | public function testReturnsTrueForCompliantVersions(Version $constrain...
FILE: tests/Unit/OrVersionConstraintGroupTest.php
class OrVersionConstraintGroupTest (line 17) | class OrVersionConstraintGroupTest extends TestCase {
method testReturnsTrueIfOneConstraintReturnsFalse (line 18) | public function testReturnsTrueIfOneConstraintReturnsFalse(): void {
method testReturnsTrueIfAllConstraintsReturnsTrue (line 35) | public function testReturnsTrueIfAllConstraintsReturnsTrue(): void {
method testReturnsFalseIfAllConstraintsReturnsFalse (line 48) | public function testReturnsFalseIfAllConstraintsReturnsFalse(): void {
FILE: tests/Unit/PreReleaseSuffixTest.php
class PreReleaseSuffixTest (line 9) | class PreReleaseSuffixTest extends TestCase {
method testGreaterThanReturnsExpectedResult (line 13) | public function testGreaterThanReturnsExpectedResult(
method greaterThanProvider (line 24) | public function greaterThanProvider() {
method testParsedValue (line 45) | public function testParsedValue(string $suffix): void {
method suffixProvider (line 50) | public function suffixProvider() {
method testLabelCanBeRetrieved (line 68) | public function testLabelCanBeRetrieved(): void {
method testCreatingWithUnsupportedLabelTypeThrowsException (line 72) | public function testCreatingWithUnsupportedLabelTypeThrowsException():...
FILE: tests/Unit/SpecificMajorAndMinorVersionConstraintTest.php
class SpecificMajorAndMinorVersionConstraintTest (line 17) | class SpecificMajorAndMinorVersionConstraintTest extends TestCase {
method versionProvider (line 18) | public function versionProvider() {
method testReturnsTrueForCompliantVersions (line 38) | public function testReturnsTrueForCompliantVersions($major, $minor, Ve...
FILE: tests/Unit/SpecificMajorVersionConstraintTest.php
class SpecificMajorVersionConstraintTest (line 17) | class SpecificMajorVersionConstraintTest extends TestCase {
method versionProvider (line 18) | public function versionProvider() {
method testReturnsTrueForCompliantVersions (line 37) | public function testReturnsTrueForCompliantVersions($major, Version $v...
FILE: tests/Unit/VersionTest.php
class VersionTest (line 17) | class VersionTest extends TestCase {
method testParsesVersionNumbers (line 29) | public function testParsesVersionNumbers(
method versionProvider (line 57) | public function versionProvider() {
method testOrigionalStringReturnsExceptedVersionString (line 74) | public function testOrigionalStringReturnsExceptedVersionString(string...
method testAsStringReturnsExceptedVersionString (line 84) | public function testAsStringReturnsExceptedVersionString(string $input...
method testIsGreaterThan (line 96) | public function testIsGreaterThan(Version $versionA, Version $versionB...
method versionGreaterThanProvider (line 100) | public function versionGreaterThanProvider(): array {
method testThrowsExceptionIfVersionStringDoesNotFollowSemVer (line 122) | public function testThrowsExceptionIfVersionStringDoesNotFollowSemVer(...
method invalidVersionStringProvider (line 127) | public function invalidVersionStringProvider(): array {
method versionStringProvider (line 135) | public function versionStringProvider() {
method testIdenticalVersionsAreConsideredEqual (line 155) | public function testIdenticalVersionsAreConsideredEqual(): void {
method testNonIdenticalVersionsAreNotConsideredEqual (line 162) | public function testNonIdenticalVersionsAreNotConsideredEqual(): void {
method testIdenticalVersionsWithBuildMetaDataAreConsideredEqual (line 169) | public function testIdenticalVersionsWithBuildMetaDataAreConsideredEqu...
method testIdenticalVersionsWithOnlyOneHavingBuildMetaDataAreNotConsideredEqual (line 176) | public function testIdenticalVersionsWithOnlyOneHavingBuildMetaDataAre...
method testIdenticalVersionsWithDifferingBuildMetaDataAreNotConsideredEqual (line 183) | public function testIdenticalVersionsWithDifferingBuildMetaDataAreNotC...
method testGetPreReleaseSuffixThrowsExceptionWhenNoneIsSet (line 190) | public function testGetPreReleaseSuffixThrowsExceptionWhenNoneIsSet():...
method testGetBuildMetadataThrowsExceptionWhenNoneIsSet (line 195) | public function testGetBuildMetadataThrowsExceptionWhenNoneIsSet(): vo...
method testHasBuildMetadataReturnsFalseWhenNoneIsSet (line 200) | public function testHasBuildMetadataReturnsFalseWhenNoneIsSet(): void {
method testBuildMetadataCanBeRetreived (line 204) | public function testBuildMetadataCanBeRetreived(): void {
Condensed preview — 45 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (87K chars).
[
{
"path": ".gitattributes",
"chars": 278,
"preview": "/tests export-ignore\n/.gitattributes export-ignore\n/.gitignore export-ignore\n/.php_cs.dist export-ign"
},
{
"path": ".gitignore",
"chars": 99,
"preview": "/.github/\n/.idea\n/.php_cs.cache\n/composer.lock\n/tools\n/vendor\nbuild/coverage\n.phpunit.result.cache\n"
},
{
"path": ".php_cs.dist",
"chars": 11419,
"preview": "<?php\n\nreturn PhpCsFixer\\Config::create()\n ->setRiskyAllowed(true)\n ->setRules(\n [\n 'align_multi"
},
{
"path": "CHANGELOG.md",
"chars": 4132,
"preview": "# Changelog\n\nAll notable changes to phar-io/version are documented in this file using the [Keep a CHANGELOG](http://keep"
},
{
"path": "LICENSE",
"chars": 1574,
"preview": "Copyright (c) 2016-2017 Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de> and contributors\nAll"
},
{
"path": "README.md",
"chars": 2384,
"preview": "# Version\n\nLibrary for handling version information and constraints\n\n[;\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/PreReleaseSuffix.php",
"chars": 1886,
"preview": "<?php declare(strict_types = 1);\nnamespace PharIo\\Version;\n\nclass PreReleaseSuffix {\n private const valueScoreMap = ["
},
{
"path": "src/Version.php",
"chars": 5997,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/VersionConstraintParser.php",
"chars": 3839,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/VersionConstraintValue.php",
"chars": 2598,
"preview": "<?php declare(strict_types = 1);\nnamespace PharIo\\Version;\n\nclass VersionConstraintValue {\n /** @var VersionNumber */"
},
{
"path": "src/VersionNumber.php",
"chars": 673,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/AbstractVersionConstraint.php",
"chars": 687,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/AndVersionConstraintGroup.php",
"chars": 983,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/AnyVersionConstraint.php",
"chars": 576,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/ExactVersionConstraint.php",
"chars": 712,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/GreaterThanOrEqualToVersionConstraint.php",
"chars": 900,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/OrVersionConstraintGroup.php",
"chars": 1023,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/SpecificMajorAndMinorVersionConstraint.php",
"chars": 956,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/SpecificMajorVersionConstraint.php",
"chars": 762,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/constraints/VersionConstraint.php",
"chars": 493,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/exceptions/Exception.php",
"chars": 424,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "src/exceptions/InvalidPreReleaseSuffixException.php",
"chars": 143,
"preview": "<?php declare(strict_types = 1);\nnamespace PharIo\\Version;\n\nclass InvalidPreReleaseSuffixException extends \\Exception im"
},
{
"path": "src/exceptions/InvalidVersionException.php",
"chars": 149,
"preview": "<?php declare(strict_types = 1);\nnamespace PharIo\\Version;\n\nclass InvalidVersionException extends \\InvalidArgumentExcept"
},
{
"path": "src/exceptions/NoBuildMetaDataException.php",
"chars": 135,
"preview": "<?php declare(strict_types = 1);\nnamespace PharIo\\Version;\n\nclass NoBuildMetaDataException extends \\Exception implements"
},
{
"path": "src/exceptions/NoPreReleaseSuffixException.php",
"chars": 138,
"preview": "<?php declare(strict_types = 1);\nnamespace PharIo\\Version;\n\nclass NoPreReleaseSuffixException extends \\Exception impleme"
},
{
"path": "src/exceptions/UnsupportedVersionConstraintException.php",
"chars": 467,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Integration/CompliesTest.php",
"chars": 2019,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Integration/VersionConstraintParserTest.php",
"chars": 7032,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/AbstractVersionConstraintTest.php",
"chars": 822,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/AndVersionConstraintGroupTest.php",
"chars": 1815,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/AnyVersionConstraintTest.php",
"chars": 1045,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/BuildMetaDataTest.php",
"chars": 1193,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/ExactVersionConstraintTest.php",
"chars": 1796,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/GreaterThanOrEqualToVersionConstraintTest.php",
"chars": 1666,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/OrVersionConstraintGroupTest.php",
"chars": 2331,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/PreReleaseSuffixTest.php",
"chars": 2126,
"preview": "<?php declare(strict_types = 1);\nnamespace PharIo\\Version;\n\nuse PHPUnit\\Framework\\TestCase;\n\n/**\n * @covers \\PharIo\\Vers"
},
{
"path": "tests/Unit/SpecificMajorAndMinorVersionConstraintTest.php",
"chars": 1416,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/SpecificMajorVersionConstraintTest.php",
"chars": 1332,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
},
{
"path": "tests/Unit/VersionTest.php",
"chars": 7007,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Version.\n *\n * (c) Arne Blankerts <arne@blankerts.de>"
}
]
About this extraction
This page contains the full source code of the phar-io/version GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 45 files (79.6 KB), approximately 20.6k tokens, and a symbol index with 148 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.