Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0bfa507

Browse files
committed
fix PathRoutingParser
1 parent 683f3a8 commit 0bfa507

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

‎src/Parser/PathRoutingParser.php‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,37 @@ final class PathRoutingParser implements Parser
1919
/** @var bool[] filePath(string) => bool(true) */
2020
private array $analysedFiles = [];
2121

22+
private bool $caseInsensitiveFilesystem;
23+
2224
public function __construct(
2325
private FileHelper $fileHelper,
2426
private Parser $currentPhpVersionRichParser,
2527
private Parser $currentPhpVersionSimpleParser,
2628
private Parser $php8Parser,
2729
)
2830
{
31+
$this->caseInsensitiveFilesystem = PHP_OS_FAMILY === 'Darwin';
2932
}
3033

3134
/**
3235
* @param string[] $files
3336
*/
3437
public function setAnalysedFiles(array $files): void
3538
{
39+
if ($this->caseInsensitiveFilesystem) {
40+
$files = array_map(static fn (string $file): string => strtolower($file), $files);
41+
}
3642
$this->analysedFiles = array_fill_keys($files, true);
3743
}
3844

45+
private function isInAnalyzedFiles(string $file): bool {
46+
if ($this->caseInsensitiveFilesystem) {
47+
$file = strtolower($file);
48+
}
49+
50+
return isset($this->analysedFiles[$file]);
51+
}
52+
3953
public function parseFile(string $file): array
4054
{
4155
$normalizedPath = $this->fileHelper->normalizePath($file, '/');
@@ -47,7 +61,7 @@ public function parseFile(string $file): array
4761
}
4862

4963
$file = $this->fileHelper->normalizePath($file);
50-
if (!isset($this->analysedFiles[$file])) {
64+
if (!$this->isInAnalyzedFiles($file)) {
5165
// check symlinked file that still might be in analysedFiles
5266
$pathParts = explode(DIRECTORY_SEPARATOR, $file);
5367
for ($i = count($pathParts); $i > 1; $i--) {
@@ -59,7 +73,7 @@ public function parseFile(string $file): array
5973
$realFilePath = realpath($file);
6074
if ($realFilePath !== false) {
6175
$normalizedRealFilePath = $this->fileHelper->normalizePath($realFilePath);
62-
if (isset($this->analysedFiles[$normalizedRealFilePath])) {
76+
if ($this->isInAnalyzedFiles($normalizedRealFilePath)) {
6377
return $this->currentPhpVersionRichParser->parseFile($file);
6478
}
6579
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /