Skip to content

Commit 61dd6d3

Browse files
committed
Revert "Fix bugs in SimpleRelativePathHelper"
This reverts commit 3473695.
1 parent 4e880dd commit 61dd6d3

File tree

2 files changed

+3
-112
lines changed

2 files changed

+3
-112
lines changed

src/File/SimpleRelativePathHelper.php

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,16 @@ class SimpleRelativePathHelper implements RelativePathHelper
66
{
77

88
/** @var string */
9-
private $directorySeparator;
9+
private $currentWorkingDirectory;
1010

11-
/** @var string */
12-
private $currentWorkingDirectory = '';
13-
14-
public function __construct(string $currentWorkingDirectory, string $directorySeparator = DIRECTORY_SEPARATOR)
11+
public function __construct(string $currentWorkingDirectory)
1512
{
16-
$this->directorySeparator = $directorySeparator;
17-
18-
if ($currentWorkingDirectory !== $directorySeparator) {
19-
$currentWorkingDirectory = rtrim($currentWorkingDirectory, $directorySeparator);
20-
}
2113
$this->currentWorkingDirectory = $currentWorkingDirectory;
2214
}
2315

2416
public function getRelativePath(string $filename): string
2517
{
26-
if ($this->currentWorkingDirectory === '') {
27-
return $filename;
28-
}
29-
30-
if ($this->currentWorkingDirectory === $this->directorySeparator) {
31-
if (strpos($filename, $this->currentWorkingDirectory) === 0) {
32-
return substr($filename, strlen($this->currentWorkingDirectory));
33-
}
34-
35-
return $filename;
36-
}
37-
38-
if (strpos($filename, $this->currentWorkingDirectory . $this->directorySeparator) === 0) {
18+
if ($this->currentWorkingDirectory !== '' && strpos($filename, $this->currentWorkingDirectory) === 0) {
3919
return substr($filename, strlen($this->currentWorkingDirectory) + 1);
4020
}
4121

tests/PHPStan/File/SimpleRelativePathHelperTest.php

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)