phar-io / version Goto Github PK
View Code? Open in Web Editor NEWLibrary for handling version information and constraints
Home Page: https://phar.io/
License: BSD 3-Clause "New" or "Revised" License
Library for handling version information and constraints
Home Page: https://phar.io/
License: BSD 3-Clause "New" or "Revised" License
Generating optimized autoload filesWarning: Ambiguous class resolution, "PharIo\Version\InvalidVersionException" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/exceptions/InvalidVersionException.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/InvalidVersionException.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\UnsupportedVersionConstraintException" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/exceptions/UnsupportedVersionConstraintException.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/UnsupportedVersionConstraintException.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\AndVersionConstraintGroup" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/AndVersionConstraintGroup.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\VersionConstraint" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/VersionConstraint.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/VersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\SpecificMajorAndMinorVersionConstraint" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/SpecificMajorAndMinorVersionConstraint.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\SpecificMajorVersionConstraint" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/SpecificMajorVersionConstraint.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\GreaterThanOrEqualToVersionConstraint" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/GreaterThanOrEqualToVersionConstraint.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\ExactVersionConstraint" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/ExactVersionConstraint.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/ExactVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\OrVersionConstraintGroup" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/OrVersionConstraintGroup.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\AbstractVersionConstraint" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/AbstractVersionConstraint.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\AnyVersionConstraint" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/AnyVersionConstraint.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/constraints/AnyVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\Exception" was found in both "/home/winardiaris/git/project/vendor/phar-io/version/src/exceptions/Exception.php" and "/home/winardiaris/git/project/vendor/phar-io/version/src/Exception.php", the first will be used.
This would help to get an overview about the API more quickly.
I'm trying to parse the version string
symfony/monolog-bundle: >=3.6
on https://packagist.org/packages/antonchernik/logging-bundle,
3^ PharIo\Version\UnsupportedVersionConstraintException^ {#4853
#message: "Version constraint >=3.6 is not supported."
#code: 0
#file: "./vendor/phar-io/version/src/VersionConstraintParser.php"
#line: 22
trace: {
./vendor/phar-io/version/src/VersionConstraintParser.php:22 { …}
A change happened in 3.0.1 which means that versions will not be output with a prefixed "v" if they started with one.
This was caused by the following change
8cef51d#diff-9cb52248cb807e881c8c2b95169d98aa095f95ee40639b13af3b9f28cc553122L42
Adding this as a regression as the CHANGELOG doesn't mention it.
I spotted this while looking into deprecated-packages/symplify#2972
Hi,
i receive this warning during the installation.
Warning: Ambiguous class resolution, "PharIo\Version\AnyVersionConstraint" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/AnyVersionConstraint.php" and "/home/dev/mySoft/vendor/phar-io/version/src/constraints/AnyVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\VersionConstraint" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/VersionConstraint.php" and "/home/dev/mySoft/vendor/phar-io/version/src/constraints/VersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\SpecificMajorAndMinorVersionConstraint" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/SpecificMajorAndMinorVersionConstraint.php" and "/home/dev/mySoft/vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\OrVersionConstraintGroup" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/OrVersionConstraintGroup.php" and "/home/dev/mySoft/vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\GreaterThanOrEqualToVersionConstraint" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php" and "/home/dev/mySoft/vendor/phar-io/version/src/GreaterThanOrEqualToVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\ExactVersionConstraint" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/constraints/ExactVersionConstraint.php" and "/home/dev/mySoft/vendor/phar-io/version/src/ExactVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\AbstractVersionConstraint" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php" and "/home/dev/mySoft/vendor/phar-io/version/src/AbstractVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\SpecificMajorVersionConstraint" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php" and "/home/dev/mySoft/vendor/phar-io/version/src/SpecificMajorVersionConstraint.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\UnsupportedVersionConstraintException" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/UnsupportedVersionConstraintException.php" and "/home/dev/mySoft/vendor/phar-io/version/src/exceptions/UnsupportedVersionConstraintException.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\Exception" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/Exception.php" and "/home/dev/mySoft/vendor/phar-io/version/src/exceptions/Exception.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\InvalidVersionException" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/InvalidVersionException.php" and "/home/dev/mySoft/vendor/phar-io/version/src/exceptions/InvalidVersionException.php", the first will be used.
Warning: Ambiguous class resolution, "PharIo\Version\AndVersionConstraintGroup" was found in both "/home/dev/mySoft/vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php" and "/home/dev/mySoft/vendor/phar-io/version/src/AndVersionConstraintGroup.php", the first will be used.
Can you fix it ?
Can i help you to fix it?
Thanks in advance
Alex
I'd love to be able to use #25 asap :)
Hello,
Context
I've wrote a solution that may be integrated in phar-io/manifest
that is able to write a manifest.xml
from parsing any composer.json
file.
Issue
I've noticed that the VersionConstraintParser
does not support logicial OR syntax represented by a single pipe.
This syntax is still used by lot of vendor / package.
See https://getcomposer.org/doc/articles/versions.md#version-range
Recommandation
I propose to add support of single pipe support for logical OR.
See https://github.com/phar-io/version/blob/3.1.0/src/VersionConstraintParser.php#L17
And https://github.com/phar-io/version/blob/3.1.0/src/VersionConstraintParser.php#L61
Expected behaviour
Prints "Phar.io version constraint: ^7.4|^8.0"
Actual behiavour
Raises Fatal error: Uncaught PharIo\Version\UnsupportedVersionConstraintException: Version constraint ^7.4|^8.0 is not supported.
Script to reproduce issue
<?php
use PharIo\Version\VersionConstraintParser;
$parser = new VersionConstraintParser();
$constraint = '^7.4|^8.0';
$versionConstraint = $parser->parse( $constraint );
var_dump('Phar.io version constraint: ' . $versionConstraint->asString());
While it is arguable whether or not the string 7.0.28-1
is semver compliant, we obviously have to face reality and deal with it.
Hey!
Would it be possible to add support for "x" and "*" for minor and patch versions?
Thanks!
Following code is generally not valid from a static perspective (note: still works at runtime)
interface MyMarker
{
}
try {
} catch (MyMarker $e) {
}
The rationale is that the contract to be followed for a symbol to be used in a catch ()
is that it should implement Throwable
.
In practice, the idea is that the interface should be extending Throwable
:
interface MyMarker extends Throwable
{
}
This currently affects following:
version/src/exceptions/Exception.php
Lines 11 to 14 in 45a2ec5
Hello @theseer
Following our recent discussion, I would like here to remember the use case I found about version string not yet supported.
Context
When we want to create a manifest for a package under development. From master branch or another one, and with latest commit not the same as the one corresponding to the latest git tag. Picking info from VCS like PHPUnit did with https://github.com/sebastianbergmann/phpunit/blob/master/build/scripts/phar-manifest.php#L3-L15
Current behaviour
Prints workaround version 0.0.0-dev
Expected behaviour
Prints version dev-master@045047b37d1dd99bf7e97487e2dc10820439f29b
Script to reproduce issue
<?php
use PharIo\Version\InvalidVersionException;
use PharIo\Version\Version;
// branch@commit_hash
$rootPackageVersion = 'dev-master@045047b37d1dd99bf7e97487e2dc10820439f29b'
$default = '0.0.0-dev';
$version = $rootPackageVersion ?? $default;
try {
new Version($version);
} catch (InvalidVersionException $e) {
$version = $default;
}
var_dump($version);
Hey,
I am working on this package today and I got this warning while running the test.
└─> phpunit --bootstrap /usr/share/php/PharIo/Version/autoload.php
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.4
Configuration: /home/gseren/tmp/version/phpunit.xml
Warning - The configuration file did not pass validation!
The following problems have been detected:
Line 10:
- Element 'testsuite': The attribute 'name' is required but missing.
Test results may not be as expected.
................................................................. 65 / 86 ( 75%)
..................... 86 / 86 (100%)
Time: 56 ms, Memory: 6.00 MB
OK (86 tests, 110 assertions)
The fix is pretty trivial, but I opened a PR with it.
Thank you for this project.
We are currently using the 2.x version and wanted to update to the new 3.x version. In the process, however, our unit tests failed.
The original statement no longer works:
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.
When parsing a version number, "0" is now always set instead of "null" for the patch default value, so that the "getPatch()->isAny()" method returns true every time. It then assumes, for example, "~7.0.0" even if you pass "~7.0" and a comparison with 7.1 then fails.
Line 114 in e478261
https://packagist.org/packages/braunstetter/choosy-type
not sure why symfony/form: ^6 is different than the rest, but composer thinks it's valid, can you change the library to support this format as well?
symfony/form ^6
https://packagist.org/packages/braunstetter/choosy-type
Version string '6' does not follow SemVer semantics
The code I'm using for this is
$version = '^6';
try {
$constraint = $parser->parse($version);
} catch (\Exception $exception) {
$this->logger->error(sprintf("%s %s\n%s\n%s",
$dependency, $version,
$this->getPackagistUrl($name),
$exception->getMessage()));
break;
}
After performing the typical »on boarding« steps (cloning, run composer install
) I would assume that I can run the PHPUnit tests, but it gives me the following error:
$ phpunit
PHPUnit 6.0.6 by Sebastian Bergmann and contributors.
Cannot open file "/var/www/projects/php/phpunit/vendor/phar-io/version/src/autoload.php".
In order to run the PHPUnit tests of this package I need to do the following steps:
$ composer global require theseer/autoload
src/autoload.php
: $ phpab src/ > src/autoload.php
This is not really obvious, however. In order to automate this process, one could add phpab as dev dependency and run the autoload building as post-install composer script. Alternatively one could use the composer autoload file vendor/autoload.php
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.