Skip to content

Commit 2a3384e

Browse files
committed
Fix path normalization issues on windows
1 parent d2c6c89 commit 2a3384e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ClassMapGenerator.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,15 @@ private function filterByNamespace(array $classes, string $filePath, string $bas
243243
}
244244
// warn only if no valid classes, else silently skip invalid
245245
if (\count($validClasses) === 0) {
246+
$cwd = realpath(self::getCwd());
247+
if ($cwd === false) {
248+
$cwd = self::getCwd();
249+
}
250+
$cwd = self::normalizePath($cwd);
251+
$shortPath = Preg::replace('{^'.preg_quote($cwd).'}', '.', $filePath, 1);
252+
$shortBasePath = Preg::replace('{^'.preg_quote($cwd).'}', '.', $basePath, 1);
253+
246254
foreach ($rejectedClasses as $class) {
247-
$shortPath = Preg::replace('{^'.preg_quote(self::getCwd()).'}', '.', $filePath, 1);
248-
$shortBasePath = Preg::replace('{^'.preg_quote(self::getCwd()).'}', '.', $basePath, 1);
249255
$this->classMap->addPsrViolation("Class $class located in $shortPath does not comply with $namespaceType autoloading standard (rule: $baseNamespace => $shortBasePath). Skipping.", $class, $filePath);
250256
}
251257

0 commit comments

Comments
 (0)