Skip to content

phpstan ignores composers exclude-from-classmap #12114

@verfriemelt-dot-org

Description

@verfriemelt-dot-org

Bug report

i have a legacy project with duplicated class definitions for legacy tests and i just moved to a new laptop and triggered errors due to that, which i did not have before.
so after investigating i can confirm that i have two files which are the culprit and lead to errors with phpstan i do not have on my old laptop.

the nature of the error is phpstan using the classes defined in the global namespace from the testhelpers instead of the correct ones.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    lib/symfony-one/test/unit/helper/DateHelperTest.php
        deleted:    lib/symfony-one/test/unit/sfContextMock.class.php

the autoloading looks like this:

  "classmap": [
            "lib",
        ],
        "exclude-from-classmap": [
            "lib/symfony-one/test"
        ],
  ]

the phpstan config looks like this:

  paths:
    - src
    - tests

  excludePaths:
    analyse:
      [...]
    analyseAndScan:
      [...]

a workaround would be to either delete the files or exclude them specifically via

  excludePaths:
    analyseAndScan:
      - lib/symfony-one/test

i cant pinpoint the reason why this works on my old machine but not on my new machine anymore, then again, colleagues reported a simmilar issue in the past, which i was unable to track down - but i expect it could be similar in nature.

Code snippet that reproduces the problem

No response

Expected output

no errors :)

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

a nice way to see the performance improvements of my new laptop 😁

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions