Skip to content

Commit

Permalink
Add backwards compatibility for older composer verions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram Roets committed May 24, 2021
1 parent cc24e2f commit 0999091
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/PrettyVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public static function getRootPackageVersion(): Version

protected static function checkProvidedPackages(string $packageName): void
{
if (! method_exists(InstalledVersions::class, 'getAllRawData')) {
if (isset(InstalledVersions::getRawData()['versions'][$packageName]['provided'])) {
throw ProvidedPackageException::create($packageName);
}
}

foreach (InstalledVersions::getAllRawData() as $installed) {
if (isset($installed['versions'][$packageName]['provided'])) {
throw ProvidedPackageException::create($packageName);
Expand All @@ -52,6 +58,12 @@ protected static function checkProvidedPackages(string $packageName): void

protected static function checkReplacedPackages(string $packageName): void
{
if (! method_exists(InstalledVersions::class, 'getAllRawData')) {
if (isset(InstalledVersions::getRawData()['versions'][$packageName]['replaced'])) {
throw ReplacedPackageException::create($packageName);
}
}

foreach (InstalledVersions::getAllRawData() as $installed) {
if (isset($installed['versions'][$packageName]['replaced'])) {
throw ReplacedPackageException::create($packageName);
Expand Down

1 comment on commit 0999091

@Wirone
Copy link

@Wirone Wirone commented on 0999091 Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jean85 looking at this commit it should be possible to use v2 of this package with Composer v1, but there is "composer-runtime-api": "^2.0.0" in require section (and compatibility table also states that v2 is only for Composer v2). Did you forget to update requirements and compatibility table?

Currently we're facing issue with many deprecation errors from getRawData and we want to upgrade, but we need Composer v1 support 😩

Please sign in to comment.