Skip to content

Commit

Permalink
directory_separator optional wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Feb 5, 2024
1 parent 41ce826 commit ee7187c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,13 @@ private function getPluginClassForPath(Codebase $codebase, string $path, string
public function shortenFileName(string $to): string
{
if (!is_file($to)) {
return preg_replace('/^' . preg_quote($this->base_dir . DIRECTORY_SEPARATOR, '/') . '?/', '', $to, 1);
// if cwd is the root directory it will be just the directory separator - trim it off first
return preg_replace(
'/^' . preg_quote(rtrim($this->base_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, '/') . '/',
'',
$to,
1,
);
}

$from = $this->base_dir;
Expand Down

0 comments on commit ee7187c

Please sign in to comment.