1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Replace requirement for package-versions with Composer 2 APIs

This commit is contained in:
Alessandro Lai 2023-03-06 09:20:36 +01:00 committed by Alessandro
parent 3a0adabf06
commit 7f26a5b473
No known key found for this signature in database
GPG Key ID: 5D9C513BE4F5798D
2 changed files with 10 additions and 3 deletions

View File

@ -25,7 +25,7 @@
"ext-tokenizer": "*",
"amphp/amp": "^2.4.2",
"amphp/byte-stream": "^1.5",
"composer/package-versions-deprecated": "^1.10.0",
"composer-runtime-api": "^2",
"composer/semver": "^1.4 || ^2.0 || ^3.0",
"composer/xdebug-handler": "^2.0 || ^3.0",
"dnoegel/php-xdg-base-dir": "^0.1.1",

View File

@ -2,6 +2,7 @@
namespace Psalm\Internal;
use Composer\InstalledVersions;
use OutOfBoundsException;
use PackageVersions\Versions;
use Phar;
@ -89,11 +90,17 @@ final class VersionUtils
{
try {
return [
self::PSALM_PACKAGE => Versions::getVersion(self::PSALM_PACKAGE),
self::PHP_PARSER_PACKAGE => Versions::getVersion(self::PHP_PARSER_PACKAGE),
self::PSALM_PACKAGE => self::getVersion(self::PSALM_PACKAGE),
self::PHP_PARSER_PACKAGE => self::getVersion(self::PHP_PARSER_PACKAGE),
];
} catch (OutOfBoundsException $ex) {
}
return null;
}
private static function getVersion(string $packageName): string
{
return InstalledVersions::getPrettyVersion($packageName)
. '@' . InstalledVersions::getReference($packageName);
}
}