Skip to content

Commit

Permalink
Fix path normalization issues on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jun 10, 2024
1 parent d2c6c89 commit 2a3384e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ClassMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,15 @@ private function filterByNamespace(array $classes, string $filePath, string $bas
}
// warn only if no valid classes, else silently skip invalid
if (\count($validClasses) === 0) {
$cwd = realpath(self::getCwd());
if ($cwd === false) {
$cwd = self::getCwd();
}
$cwd = self::normalizePath($cwd);
$shortPath = Preg::replace('{^'.preg_quote($cwd).'}', '.', $filePath, 1);
$shortBasePath = Preg::replace('{^'.preg_quote($cwd).'}', '.', $basePath, 1);

foreach ($rejectedClasses as $class) {
$shortPath = Preg::replace('{^'.preg_quote(self::getCwd()).'}', '.', $filePath, 1);
$shortBasePath = Preg::replace('{^'.preg_quote(self::getCwd()).'}', '.', $basePath, 1);
$this->classMap->addPsrViolation("Class $class located in $shortPath does not comply with $namespaceType autoloading standard (rule: $baseNamespace => $shortBasePath). Skipping.", $class, $filePath);
}

Expand Down

0 comments on commit 2a3384e

Please sign in to comment.