Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Command/ErrorFormatter/TableErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function formatErrors(
}

if (getenv('TERMINAL_EMULATOR') === 'JetBrains-JediTerm') {
$title = $this->relativePathHelper->getRelativePath($filePath);
$title = $this->simpleRelativePathHelper->getRelativePath($filePath);
$message .= sprintf("\nat %s:%d", $title, $error->getLine() ?? 0);

} elseif (is_string($this->editorUrl)) {
Expand Down
24 changes: 24 additions & 0 deletions tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,30 @@ public function testBug13317(): void
);
}

public function testJetBrainsTerminalRelativePath(): void
{
putenv('TERMINAL_EMULATOR=JetBrains-JediTerm');

// FuzzyRelativePathHelper trims path segments based on analysed paths.
$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH, [self::DIRECTORY_PATH . '/rel'], '/');

$formatter = new TableErrorFormatter(
$relativePathHelper,
new SimpleRelativePathHelper(self::DIRECTORY_PATH),
new CiDetectedErrorFormatter(
new GithubErrorFormatter($relativePathHelper),
new TeamcityErrorFormatter($relativePathHelper),
),
false,
null,
null,
);
$error = new Error('Test', 'Foo.php', 12, filePath: self::DIRECTORY_PATH . '/rel/Foo.php');
$formatter->formatErrors(new AnalysisResult([$error], [], [], [], [], false, null, true, 0, false, []), $this->getOutput(true));

$this->assertStringContainsString('at rel/Foo.php:12', $this->getOutputContent(true));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not failing even if I revert the change in src/.

}

private function createErrorFormatter(?string $editorUrl, ?string $editorUrlTitle = null): TableErrorFormatter
{
$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), self::DIRECTORY_PATH, [], '/');
Expand Down
Loading