Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 9 additions & 0 deletions tests/Integration/Composer/ComposerFileToClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public function testPsr4WithRelativePathComponents(): void
$this->assertFilePathToClassName('/psr4/Foo/../Foo/Class.php', ['Acme\\Test\\Foo\\Class']);
}

/**
* @testdox PSR-4 file with symlinked path components
*/
public function testPsr4Symlinked(): void
{
$this->loadExample('psr4-symlinked-project.json');
$this->assertFilePathToClassName('/symlinked-package/Class.php', ['Acme\\Test\\Class']);
}

/**
* @testdox PSR-4 multiple matching prefixes
*/
Expand Down
18 changes: 18 additions & 0 deletions tests/Integration/Composer/composers/psr4-symlinked-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "dantleech/basic",
"authors": [
{
"name": "dantleech",
"email": "dan.t.leech@gmail.com"
}
],
"repositories": [
{
"type": "path",
"url": "./*"
}
],
"require": {
"dantleech/symlinked": "1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Acme\Test;

class Class
{
}
16 changes: 16 additions & 0 deletions tests/Integration/Composer/project/symlinked-package/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "dantleech/symlinked",
"version": "1.0.0",
"authors": [
{
"name": "dantleech",
"email": "dan.t.leech@gmail.com"
}
],
"require": {},
"autoload": {
"psr-4": {
"Acme\\Test\\": "./"
}
}
}
Loading