Skip to content

Commit

Permalink
Removed LegacyVersions (muglug/package-versions-56) support
Browse files Browse the repository at this point in the history
Fixes #21
  • Loading branch information
weirdan committed Aug 28, 2020
1 parent 4883024 commit 01d9f30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
composer.lock
vendor
tests/_output/*
11 changes: 4 additions & 7 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Composer\InstalledVersions;
use Composer\Semver\Semver;
use Composer\Semver\VersionParser;
use Muglug\PackageVersions\Versions as LegacyVersions;
use PackageVersions\Versions;
use PHPUnit\Framework\Assert;
use Behat\Gherkin\Node\TableNode;
Expand Down Expand Up @@ -474,19 +473,17 @@ function (array $error): array {

private function getShortVersion(string $package): string
{
/** @psalm-suppress DeprecatedClass Support of legacy code */
/** @psalm-suppress DeprecatedClass Versions is marked deprecated for no good reason */
if (class_exists(InstalledVersions::class)) {
/** @psalm-suppress UndefinedClass Composer\InstalledVersions is undefined when using Composer 1.x */
return (string) InstalledVersions::getPrettyVersion($package);
} elseif (class_exists(Versions::class)) {
/** @psalm-suppress UndefinedClass psalm 3.0 ignores class_exists check */
/** @psalm-suppress ArgumentTypeCoercion Versions::getVersion() has too narrow a signature */
$version = (string) Versions::getVersion($package);
} elseif (class_exists(LegacyVersions::class)) {
$version = (string) LegacyVersions::getVersion($package);
} else {
throw new RuntimeException(
'Neither muglug/package-versions-56 nor ocramius/package-version is available,'
. ' cannot determine versions'
'Cannot determine versions. Neither of composer:2+,'
. ' ocramius/package-version or composer/package-versions-deprecated are installed.'
);
}

Expand Down

0 comments on commit 01d9f30

Please sign in to comment.