File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -839,9 +839,15 @@ static function (string $variance): TemplateTypeVariance {
839839 return new ErrorType ();
840840 }
841841
842- // Check for a generic type alias (e.g. ProviderRequest<AppraisalFilter>) before
843- // falling through to class-based generic resolution.
844- $ genericTypeAlias = $ this ->findGenericTypeAlias ($ typeNode ->type ->name , $ nameScope );
842+ // Check for a generic type alias (e.g. MyList<string>) before falling through to
843+ // class-based generic resolution, but only when the name is not itself a resolvable
844+ // class — in that case the class-based path must win to preserve backward compatibility
845+ // (a type alias like BelongsTo<T, U> = \Eloquent\BelongsTo<T, U> should still produce
846+ // the same GenericObjectType that class-based resolution would have given).
847+ $ resolvedGenericName = $ nameScope ->resolveStringName ($ typeNode ->type ->name );
848+ $ genericTypeAlias = !$ this ->getReflectionProvider ()->hasClass ($ resolvedGenericName )
849+ ? $ this ->findGenericTypeAlias ($ typeNode ->type ->name , $ nameScope )
850+ : null ;
845851 if ($ genericTypeAlias !== null ) {
846852 $ templateNodes = $ genericTypeAlias ->getTemplateTagValueNodes ();
847853 $ totalParams = count ($ templateNodes );
You can’t perform that action at this time.
0 commit comments