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 @@ -874,9 +874,15 @@ static function (string $variance): TemplateTypeVariance {
874874 return new ErrorType ();
875875 }
876876
877- // Check for a generic type alias (e.g. ProviderRequest<AppraisalFilter>) before
878- // falling through to class-based generic resolution.
879- $ genericTypeAlias = $ this ->findGenericTypeAlias ($ typeNode ->type ->name , $ nameScope );
877+ // Check for a generic type alias (e.g. MyList<string>) before falling through to
878+ // class-based generic resolution, but only when the name is not itself a resolvable
879+ // class — in that case the class-based path must win to preserve backward compatibility
880+ // (a type alias like BelongsTo<T, U> = \Eloquent\BelongsTo<T, U> should still produce
881+ // the same GenericObjectType that class-based resolution would have given).
882+ $ resolvedGenericName = $ nameScope ->resolveStringName ($ typeNode ->type ->name );
883+ $ genericTypeAlias = !$ this ->getReflectionProvider ()->hasClass ($ resolvedGenericName )
884+ ? $ this ->findGenericTypeAlias ($ typeNode ->type ->name , $ nameScope )
885+ : null ;
880886 if ($ genericTypeAlias !== null ) {
881887 $ templateNodes = $ genericTypeAlias ->getTemplateTagValueNodes ();
882888 $ totalParams = count ($ templateNodes );
You can’t perform that action at this time.
0 commit comments