Skip to content

In JetBrains Terminal TableErrorFormatter loses directory context due to https://github.com/phpstan/phpstan-src/pull/4369 #13697

@caufang

Description

@caufang

Bug report

I ran into the same problem this person did: phpstan/phpstan-src#4369 (comment)

The $this->relativePathHelper on this line seems like it should be replaced with $this->simpleRelativePathHelper.

https://github.com/phpstan/phpstan-src/blob/bab0af7aff876e8dee3ed817e114c9261454d6a4/src/Command/ErrorFormatter/TableErrorFormatter.php#L113

As it currently is, relativePathHelper seems to remove any folders that are common to all files that are currently being analyzed. If all the files are in a subdirectory of the current working directory, that subdirectory will be removed from all displayed paths, and then the terminal can no longer match CWD-relative paths.

Example:

Path relative to CWD and phpstan.neon file:
public/admin/user_activity.php

Image

To test my hypothesis, I set and environment variable in the PhpStorm terminal settings
TERMINAL_EMULATOR=NONE
Which takes precedence.

Setting my config to use these:

    editorUrlTitle: "\nat %%relFile%%:%%line%%"
    editorUrl: "%%relFile%%:%%line%%"

because %%relFile%% comes from simpleRelativePathHelper, gives a properly clickable link:

Image

So, all that leads me to believe that switching to simpleRelativePathHelper will resolve the issue.

Code snippet that reproduces the problem

No response

Expected output

Clickable link to file+line in JetBrains terminal.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions