Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b973b5f
first pass
shmax Apr 1, 2026
eb67c21
enforce required generic params
shmax Apr 1, 2026
6fdb88f
more tests
shmax Apr 1, 2026
b27d26e
tests for invalud usage
shmax Apr 1, 2026
4f18071
fix regression
shmax Apr 1, 2026
95abc98
add more scenarios to test fixture
shmax Apr 1, 2026
f529784
remove empty patch
shmax Apr 1, 2026
590daa6
coalesce to empty array
shmax Apr 1, 2026
b8e0c55
lint
shmax Apr 1, 2026
a94b14b
fix use function ordering
shmax Apr 1, 2026
beedafb
fix generic alias resolution: skip alias path when name resolves to a…
shmax Apr 1, 2026
e023f92
remove resolveWithDefaults: bare generic alias usage restores old Tem…
shmax Apr 1, 2026
04c8aec
fix phpstan self-analysis errors: ignore property.notFound, add null …
shmax Apr 1, 2026
0195d7d
remove ignore
shmax Apr 1, 2026
95ae9e4
add property.notFound baseline entry for PHP < 8.0 (phpdoc-parser lac…
shmax Apr 1, 2026
2fd32f3
move property.notFound baseline entry to universal phpstan-baseline.n…
shmax Apr 1, 2026
89423b3
fix generic alias bare-usage resolution and data-provider parameter s…
shmax Apr 2, 2026
6c7322d
update baseline after rebase onto 2.1.x
shmax Apr 2, 2026
2321f59
add temp patches
shmax Apr 2, 2026
5726a40
use LateResolvableType
shmax Apr 2, 2026
6426482
remove
shmax Apr 2, 2026
fb9203b
lint
shmax Apr 2, 2026
d7fe98c
fix array vs list error
shmax Apr 2, 2026
e3aebe9
remove dead code
shmax Apr 2, 2026
ef31211
fold getRawGenericTypeAliasesUsage into getNonGenericObjectTypesWithG…
shmax Apr 15, 2026
106b589
update lock hash
shmax Apr 15, 2026
45ba91b
lint
shmax Apr 15, 2026
57a2395
remove unnecessary BC coverage from generic type alias resolution
shmax Apr 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix generic alias resolution: skip alias path when name resolves to a…
… known class
  • Loading branch information
shmax committed Apr 15, 2026
commit beedafbf1f2faf6c74f266bdea7c0d1fb0efbea7
12 changes: 9 additions & 3 deletions src/PhpDoc/TypeNodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,15 @@ static function (string $variance): TemplateTypeVariance {
return new ErrorType();
}

// Check for a generic type alias (e.g. ProviderRequest<AppraisalFilter>) before
// falling through to class-based generic resolution.
$genericTypeAlias = $this->findGenericTypeAlias($typeNode->type->name, $nameScope);
// Check for a generic type alias (e.g. MyList<string>) before falling through to
// class-based generic resolution, but only when the name is not itself a resolvable
// class — in that case the class-based path must win to preserve backward compatibility
// (a type alias like BelongsTo<T, U> = \Eloquent\BelongsTo<T, U> should still produce
// the same GenericObjectType that class-based resolution would have given).
$resolvedGenericName = $nameScope->resolveStringName($typeNode->type->name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this BC coverage. It's true that MyList<string> would be resolved to an actual class even if MyList type alias existed, but who the hell would do that...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Removed, thank you.

$genericTypeAlias = !$this->getReflectionProvider()->hasClass($resolvedGenericName)
? $this->findGenericTypeAlias($typeNode->type->name, $nameScope)
: null;
if ($genericTypeAlias !== null) {
$templateNodes = $genericTypeAlias->getTemplateTagValueNodes();
$totalParams = count($templateNodes);
Expand Down