Skip to content

Commit 023cce7

Browse files
committed
Fix double slashes in path for Psr4Info - #56
1 parent 2bd308f commit 023cce7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Package/Psr4Info.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ public function getPath(string $fqcn): string
110110
public function getFilenameFromPathAndName(string $path, string $name): string
111111
{
112112
$filePath = $this->getSourceFolder() . DIRECTORY_SEPARATOR;
113+
$filePath .= $this->normalizePath($path) . DIRECTORY_SEPARATOR;
113114

114-
if ($path = \trim($path, '/')) {
115-
$filePath .= $this->normalizePath($path) . DIRECTORY_SEPARATOR;
116-
}
115+
$filePath = \str_replace('//', '/', $filePath);
117116

118117
return $filePath . $name . '.php';
119118
}

tests/Package/Psr4InfoTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public function it_can_be_created_from_composer(): void
4242

4343
$this->assertSame('OpenCodeModelingTest\\CodeAst', $psr4InfoList[3]->getPackagePrefix());
4444
$this->assertSame('/service/tests', $psr4InfoList[3]->getSourceFolder());
45+
46+
$this->assertSame(
47+
'/service/src/Domain/Model/Building/Building.php',
48+
$psr4InfoList[0]->getFilenameFromPathAndName('/service/src/Domain/Model/Building', 'Building')
49+
);
50+
$this->assertSame(
51+
'/service/src/Domain/Model/Building/Building.php',
52+
$psr4InfoList[0]->getFilenameFromPathAndName('Domain/Model/Building', 'Building')
53+
);
4554
}
4655

4756
/**

0 commit comments

Comments
 (0)