Skip to content

Commit 78b109e

Browse files
committed
Drop some unused helper code
1 parent 2427228 commit 78b109e

File tree

4 files changed

+7
-40
lines changed

4 files changed

+7
-40
lines changed

src/File/FuzzyRelativePathHelper.php

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,15 @@ class FuzzyRelativePathHelper implements RelativePathHelper
4848
/**
4949
* @param RelativePathHelper $fallbackRelativePathHelper
5050
* @param string $currentWorkingDirectory
51-
* @param string[] $analysedPaths
52-
* @param string|null $directorySeparator
5351
*/
5452
public function __construct(
5553
RelativePathHelper $fallbackRelativePathHelper,
56-
string $currentWorkingDirectory,
57-
array $analysedPaths,
58-
?string $directorySeparator = null
54+
string $currentWorkingDirectory
5955
)
6056
{
6157
$this->fallbackRelativePathHelper = $fallbackRelativePathHelper;
62-
if ($directorySeparator === null) {
63-
$directorySeparator = DIRECTORY_SEPARATOR;
64-
}
6558

66-
$this->directorySeparator = $directorySeparator;
59+
$this->directorySeparator = DIRECTORY_SEPARATOR;
6760
$pathBeginning = null;
6861
$pathToTrimArray = null;
6962
$trimBeginning = static function (string $path): array {
@@ -89,40 +82,14 @@ public function __construct(
8982
[$pathBeginning, $currentWorkingDirectory] = $trimBeginning($currentWorkingDirectory);
9083

9184
/** @var string[] $pathToTrimArray */
92-
$pathToTrimArray = explode($directorySeparator, $currentWorkingDirectory);
93-
}
94-
foreach ($analysedPaths as $pathNumber => $path) {
95-
[$tempPathBeginning, $path] = $trimBeginning($path);
96-
97-
/** @var string[] $pathArray */
98-
$pathArray = explode($directorySeparator, $path);
99-
$pathTempParts = [];
100-
foreach ($pathArray as $i => $pathPart) {
101-
if (\Nette\Utils\Strings::endsWith($pathPart, '.php')) {
102-
continue;
103-
}
104-
if (!isset($pathToTrimArray[$i])) {
105-
if ($pathNumber !== 0) {
106-
$pathToTrimArray = $pathTempParts;
107-
continue 2;
108-
}
109-
} elseif ($pathToTrimArray[$i] !== $pathPart) {
110-
$pathToTrimArray = $pathTempParts;
111-
continue 2;
112-
}
113-
114-
$pathTempParts[] = $pathPart;
115-
}
116-
117-
$pathBeginning = $tempPathBeginning;
118-
$pathToTrimArray = $pathTempParts;
85+
$pathToTrimArray = explode($this->directorySeparator, $currentWorkingDirectory);
11986
}
12087

12188
if ($pathToTrimArray === null || count($pathToTrimArray) === 0) {
12289
return;
12390
}
12491

125-
$pathToTrim = $pathBeginning . implode($directorySeparator, $pathToTrimArray);
92+
$pathToTrim = $pathBeginning . implode($this->directorySeparator, $pathToTrimArray);
12693
$realPathToTrim = realpath($pathToTrim);
12794
if ($realPathToTrim !== false) {
12895
$pathToTrim = $realPathToTrim;

tests/ErrorFormatter/GithubErrorFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function testFormatErrors(
189189
string $expected
190190
): void
191191
{
192-
$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH, [], '/');
192+
$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH);
193193
$formatter = new GithubErrorFormatter(
194194
$relativePathHelper,
195195
new TableErrorFormatter($relativePathHelper, false)

tests/ErrorFormatter/TableErrorFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function testFormatErrors(
174174
string $expected
175175
): void
176176
{
177-
$formatter = new TableErrorFormatter(new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH, [], '/'), false);
177+
$formatter = new TableErrorFormatter(new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH), false);
178178

179179
$this->assertSame($exitCode, $formatter->formatErrors(
180180
$this->getAnalysisResult($numFileErrors, $numGenericErrors),

tests/ErrorFormatter/TeamcityErrorFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function testFormatErrors(
123123
string $expected
124124
): void
125125
{
126-
$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH, [], '/');
126+
$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH);
127127
$formatter = new TeamcityErrorFormatter(
128128
$relativePathHelper
129129
);

0 commit comments

Comments
 (0)