diff --git a/CHANGELOG.md b/CHANGELOG.md index 76a38357..36ed03e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles. ## [Unreleased] +### Changed + +- [Application version strategy](https://github.com/llaville/php-compat-info/issues/267) : `composer/package-versions-deprecated` is used to handle version in Composer/Git strategy + +### Removed + +- Removes usage of `jean85/pretty-package-versions` package to handle Composer/Git version strategy + ## [5.3.0] - 2020-07-08 ### Changed diff --git a/composer.json b/composer.json index 3531d704..f9ca9d87 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "ext-pdo_sqlite": "*", "bartlett/php-reflect": "^4.4", "bartlett/php-compatinfo-db": "^2.0", - "jean85/pretty-package-versions": "^1.5", + "composer/package-versions-deprecated": "^1.8", "psr/log": "^1.0" }, "require-dev": { diff --git a/src/Bartlett/CompatInfo/Console/Application.php b/src/Bartlett/CompatInfo/Console/Application.php index c3eddd5d..4278d7fb 100644 --- a/src/Bartlett/CompatInfo/Console/Application.php +++ b/src/Bartlett/CompatInfo/Console/Application.php @@ -16,9 +16,9 @@ use Bartlett\CompatInfo\Util\Database; use Bartlett\Reflect\Console\Application as BaseApplication; -use Jean85\PrettyVersions; +use PackageVersions\Versions; -use OutOfBoundsException; +use function substr_count; /** * Console Application. @@ -32,7 +32,7 @@ class Application extends BaseApplication { public const NAME = 'phpCompatInfo'; - public const VERSION = '5.3.x-dev'; + public const VERSION = '5.4.x-dev'; /** * @link http://patorjk.com/software/taag/#p=display&f=Standard&t=phpCompatInfo @@ -45,13 +45,21 @@ class Application extends BaseApplication |_| |_| |_| "; - - public function __construct() + public function __construct(string $version = 'UNKNOWN') { - try { - $version = PrettyVersions::getVersion('bartlett/php-compatinfo')->getPrettyVersion(); - } catch (OutOfBoundsException $e) { + if ('UNKNOWN' === $version) { + // composer or git outside world strategy $version = self::VERSION; + } elseif (substr_count($version, '.') === 2) { + // release is in X.Y.Z format + } else { + // composer or git strategy + $version = Versions::getVersion('bartlett/php-compatinfo'); + list($ver, ) = explode('@', $version); + + if (strpos($ver, 'dev') === false) { + $version = $ver; + } } parent::__construct(self::NAME, $version); }