Skip to content

Commit

Permalink
fix: normalize path separator
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Dec 1, 2024
1 parent 0b99357 commit ed1ce62
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Iterator/ClassMapIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static function (string $path): void {

foreach ($this->classMap as $className => $path) {
$path = PathNormalizer::resolvePath($path);
if ($this->pathCallback && ! ($this->pathCallback)($path)) {
if ($this->pathCallback && ! ($this->pathCallback)(PathNormalizer::normalize($path))) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Iterator/FilteredComposerIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function searchInClassMap(): Generator
continue;
}

if ($this->pathCallback && ! ($this->pathCallback)($file)) {
if ($this->pathCallback && ! ($this->pathCallback)(PathNormalizer::normalize($file))) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Iterator/OfflineIteratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function notPath(array $patterns): self

private function accept(string $path): bool
{
if ($this->pathCallback && ! ($this->pathCallback)($path)) {
if ($this->pathCallback && ! ($this->pathCallback)(PathNormalizer::normalize($path))) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Iterator/Psr0Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class_exists($class, true);
continue;
}

if ($this->pathCallback && ! ($this->pathCallback)($path)) {
if ($this->pathCallback && ! ($this->pathCallback)(PathNormalizer::normalize($path))) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Iterator/Psr4Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class_exists($class, true);
continue;
}

if ($this->pathCallback && ! ($this->pathCallback)($path)) {
if ($this->pathCallback && ! ($this->pathCallback)(PathNormalizer::normalize($path))) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Iterator/RecursiveIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function getGenerator(): Generator
continue;
}

if ($this->pathCallback && ! ($this->pathCallback)($path)) {
if ($this->pathCallback && ! ($this->pathCallback)(PathNormalizer::normalize($path))) {
continue;
}

Expand Down
8 changes: 8 additions & 0 deletions lib/PathNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

final class PathNormalizer
{
/**
* Normalizes path separator to '/'.
*/
public static function normalize(string $path): string
{
return str_replace(DIRECTORY_SEPARATOR, '/', $path);
}

/**
* Resolve a path.
*
Expand Down

0 comments on commit ed1ce62

Please sign in to comment.