Skip to content

Commit

Permalink
Merge pull request #124 from asgrim/improve-dependency-resolution-fai…
Browse files Browse the repository at this point in the history
…lure-message

Improve messaging when dependencies are not resolved and there is no Composer messaging
  • Loading branch information
asgrim authored Nov 21, 2024
2 parents dbfd3a6 + 2d67fea commit 9081d5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ComposerIntegration/PieInstalledJsonMetadataKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Php\Pie\ComposerIntegration;

/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
enum PieInstalledJsonMetadataKeys: string
{
case TargetPlatformPhpPath = 'pie-target-platform-php-path';
Expand Down
5 changes: 3 additions & 2 deletions src/DependencyResolver/UnableToResolveRequirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public static function fromRequirement(
$errors = $io->errors;

return new self(sprintf(
'Unable to find an installable package %s%s%s',
'Unable to find an installable package %s for %s, with minimum stability %s.%s',
$requestedPackageAndVersion->package,
$requestedPackageAndVersion->version !== null ? sprintf(' for version %s.', $requestedPackageAndVersion->version) : '.',
$requestedPackageAndVersion->version !== null ? sprintf('version %s', $requestedPackageAndVersion->version) : 'the latest compatible version',
DetermineMinimumStability::fromRequestedVersion($requestedPackageAndVersion->version),
count($errors) ? "\n\n" . implode("\n\n", array_map(static fn ($e) => strip_tags($e), $errors)) : '',
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testFromRequirementWithVersion(): void

$exception = UnableToResolveRequirement::fromRequirement(new RequestedPackageAndVersion('foo/bar', '^1.2'), $io);

self::assertSame("Unable to find an installable package foo/bar for version ^1.2.\n\nmessage1\n\nmessage3\n\nmessage4", $exception->getMessage());
self::assertSame("Unable to find an installable package foo/bar for version ^1.2, with minimum stability stable.\n\nmessage1\n\nmessage3\n\nmessage4", $exception->getMessage());
}

public function testFromRequirementWithoutVersion(): void
Expand All @@ -66,6 +66,6 @@ public function testFromRequirementWithoutVersion(): void

$exception = UnableToResolveRequirement::fromRequirement(new RequestedPackageAndVersion('foo/bar', null), $io);

self::assertSame("Unable to find an installable package foo/bar.\n\nmessage1\n\nmessage3\n\nmessage4", $exception->getMessage());
self::assertSame("Unable to find an installable package foo/bar for the latest compatible version, with minimum stability stable.\n\nmessage1\n\nmessage3\n\nmessage4", $exception->getMessage());
}
}

0 comments on commit 9081d5c

Please sign in to comment.