File tree Expand file tree Collapse file tree
src/main/php/lang/reflect Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,7 +126,15 @@ public function getReturnType(): Type {
126126 $ r = $ details [DETAIL_RETURNS ] ?? null ;
127127 return $ r ? ltrim ($ r , '& ' ) : null ;
128128 };
129- return Type::resolve ($ this ->_reflect ->getReturnType (), $ this ->resolve (), $ api ) ?? Type::$ VAR ;
129+
130+ // Check "self" (and declaring class, see https://github.com/php/php-src/issues/18373)
131+ $ decl = $ this ->_reflect ->getDeclaringClass ();
132+ $ type = $ this ->_reflect ->getReturnType ();
133+ if ($ type instanceof \ReflectionNamedType && (PHP_VERSION_ID >= 80500 ? $ decl ->getName () : 'self ' ) === $ type ->getName ()) {
134+ return ($ specific = $ api ()) ? Type::named ($ specific , $ this ->resolve ()) : new XPClass ($ decl );
135+ }
136+
137+ return Type::resolve ($ type , $ this ->resolve (), $ api ) ?? Type::$ VAR ;
130138 }
131139
132140 /** Retrieve return type name */
You can’t perform that action at this time.
0 commit comments