Skip to content

Using phpstan-import-type between classes makes alias unresolvable #11463

Closed

Description

@eigan

Bug report

If you have two classes which depends on eachother with phpstan-import-type, then the type imported will be unresolveable.

Code snippet that reproduces the problem

https://phpstan.org/r/30361727-a436-4c1a-ac19-19a2f6ebfb21

Expected output

No errors. PHPStan should be able to resolve the type.

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

PHPStan helps us every day 🎉

Activity

  1. added this to the Easy fixes milestone on Aug 6, 2024
  2. theodorejb commented on Nov 17, 2024

    @theodorejb

    I am also experiencing this issue. With Psalm this works as expected, but for some reason not with PHPStan. As a workaround, the @phpstan-type declarations can all be moved to the same class, but that isn't very clean with large projects.

  3. phpstan-bot commented on Feb 19, 2026

    @phpstan-bot
    Contributor

    @eigan After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:

    @@ @@
    -13: PHPDoc tag @param for parameter $bar contains unresolvable type.
    +No errors
  4. added a commit that references this issue on Feb 19, 2026
    8717c5d
  5. staabm commented on Feb 19, 2026

    @staabm
    Contributor
  6. added a commit that references this issue on Feb 19, 2026
    8882d85
  7. github-actions commented on Mar 23, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  8. locked as resolved and limited conversation to collaborators on Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions