Skip to content

Commit

Permalink
Fix case where installed path is symlink
Browse files Browse the repository at this point in the history
One can install packages from a local path via composers repositories
type "path".
Those are typically symlinks which were not resolved.
We therefore add a realpath() call, but falling back to old behavior if
it didn't resolve. That way we keep independent of realpath() as
requested by the inline comment.

Resolves: phpactor/phpactor#2727
  • Loading branch information
d-s-codappix committed Sep 4, 2024
1 parent fad4fde commit 06b218f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Adapter/Composer/ComposerFileToClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ private function populateCandidates(FilePath $filePath, array $prefixes)
$pathPrefixes = (array) $pathPrefixes;

// remove any relativeness from the paths
//
// TODO: realpath will return void if the path does not exist
// we should not depend on the file path existing.
// we should not depend on the file path existing.
$pathPrefixes = array_map(function ($pathPrefix) {
return Path::canonicalize($pathPrefix);
$canonicalizedPath = Path::canonicalize($pathPrefix);
$realPath = realpath($canonicalizedPath);
return $realPath ?: $canonicalizedPath;
}, $pathPrefixes);

foreach ($pathPrefixes as $pathPrefix) {
Expand Down

0 comments on commit 06b218f

Please sign in to comment.