diff --git a/src/Error.php b/src/Error.php index a6c42651..0c8d37cc 100644 --- a/src/Error.php +++ b/src/Error.php @@ -69,7 +69,14 @@ public function getFilePath() */ public function getShortFilePath() { - return str_replace(getcwd(), '', $this->filePath); + $cwd = getcwd(); + + if ($cwd === '/') { + // For root directory in unix, do not modify path + return $this->filePath; + } + + return preg_replace('/' . preg_quote($cwd, '/') . '/', '', $this->filePath, 1); } /**