Skip to content

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

Merged
staabm merged 4 commits intophpstan:2.1.xfrom
staabm:bug11463
Feb 19, 2026
Merged

Fix #11463: Using phpstan-import-type between classes makes alias unresolvable#4997
staabm merged 4 commits intophpstan:2.1.xfrom
staabm:bug11463

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Feb 19, 2026

inspired by #4976

Fixes phpstan/phpstan#11463

phpstan-bot and others added 3 commits February 19, 2026 16:28
…solvable

- When two classes have mutual @phpstan-import-type tags (FooType imports Bar
  from BarType, BarType imports Foo from FooType), the circular detection in
  ClassReflection::getTypeAliases() was too aggressive
- The fix returns local type aliases (defined via @phpstan-type) when circular
  import resolution is detected, since local aliases don't depend on imports
- Added regression test in tests/PHPStan/Rules/PhpDoc/data/bug-11463.php

Closes phpstan/phpstan#11463
@staabm staabm marked this pull request as ready for review February 19, 2026 15:35
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm staabm merged commit 8717c5d into phpstan:2.1.x Feb 19, 2026
637 of 642 checks passed
@staabm staabm deleted the bug11463 branch February 19, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments