yamadashy/phpstan-friendly-formatter

relative paths do not work for configured phpstan paths

Closed this issue ยท 3 comments

in our projects we have a phpstan.neon in the projects root folder like

parameters:
    level: 8
    paths:
        - packages/phpstan-extensions/src
        - packages/phpstan-rules/src
        - packages/phpstan-formatters/src

in folder
/projects/projectA/phpstan.neon

when a error for a php file is printed it looks like

> vendor/bin/phpstan analyse -c phpstan.neon.dist
 33/33 [============================] 100%

โฏ phpstan-formatters\src\ForgivingGithubErrorFormatter.php
------------------------------------------------------------

  โœ˜ Undefined variable: $x
  ๐Ÿชช  variable.undefined
    36|     public function formatErrors(AnalysisResult $analysisResult, Output $output): int
    37|     {
  > 38|         $y = $x / 0;
    39|         foreach ($analysisResult->getFileSpecificErrors() as $fileSpecificError) {
    40|             $metas = [

๐Ÿ“Š Error Identifier Summary:
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  1  variable.undefined

 [ERROR] Found 1 error

the relative paths constructed in the error output does not match the filesystem.
the error formatted constructed
/projects/projectA/phpstan-formatters/src/ForgivingGithubErrorFormatter.php

while correct would be
/projects/projectA/packages/phpstan-formatters/src/ForgivingGithubErrorFormatter.php

Thank you for bringing this to our attention!
I'll look into this path resolution issue as soon as possible. Your detailed report is very helpful for me to understand and address the problem quickly.

Hi, @staabm !
I apologize for the delay in my investigation.

I'm having difficulty reproducing this issue locally. Does this problem also occur when using the --error-format table option?

I'd like to determine if this is an issue that affects the default table formatter as well, or if it's specific to the friendly formatter. Could you please check and let us know?

Thank you again for your help in troubleshooting this.

you are right, that the same error happens in the table-formatter