@@ -220,7 +220,7 @@ public function merge(array $parents, array $parentPhpDocBlocks): self
220
220
$ result ->typeAliasTags = $ this ->getTypeAliasTags ();
221
221
$ result ->typeAliasImportTags = $ this ->getTypeAliasImportTags ();
222
222
$ result ->assertTags = self ::mergeAssertTags ($ this ->getAssertTags (), $ parents , $ parentPhpDocBlocks );
223
- $ result ->selfOutTypeTag = $ this ->getThisOutTag ( );
223
+ $ result ->selfOutTypeTag = self :: mergeSelfOutTypeTags ( $ this ->getSelfOutTag (), $ parents );
224
224
$ result ->deprecatedTag = self ::mergeDeprecatedTags ($ this ->getDeprecatedTag (), $ parents );
225
225
$ result ->isDeprecated = $ result ->deprecatedTag !== null ;
226
226
$ result ->isInternal = $ this ->isInternal ();
@@ -302,7 +302,7 @@ public function changeParameterNamesByMapping(array $parameterNameMapping): self
302
302
$ self ->typeAliasTags = $ this ->typeAliasTags ;
303
303
$ self ->typeAliasImportTags = $ this ->typeAliasImportTags ;
304
304
$ self ->assertTags = $ assertTags ;
305
- $ self ->selfOutTypeTag = $ this ->getThisOutTag () ;
305
+ $ self ->selfOutTypeTag = $ this ->selfOutTypeTag ;
306
306
$ self ->deprecatedTag = $ this ->deprecatedTag ;
307
307
$ self ->isDeprecated = $ this ->isDeprecated ;
308
308
$ self ->isInternal = $ this ->isInternal ;
@@ -528,7 +528,7 @@ public function getAssertTags(): array
528
528
return $ this ->assertTags ;
529
529
}
530
530
531
- public function getThisOutTag (): ?SelfOutTypeTag
531
+ public function getSelfOutTag (): ?SelfOutTypeTag
532
532
{
533
533
if ($ this ->selfOutTypeTag === false ) {
534
534
$ this ->selfOutTypeTag = $ this ->phpDocNodeResolver ->resolveSelfOutTypeTag (
@@ -811,6 +811,25 @@ private static function mergeAssertTags(array $assertTags, array $parents, array
811
811
return $ assertTags ;
812
812
}
813
813
814
+ /**
815
+ * @param array<int, self> $parents
816
+ */
817
+ private static function mergeSelfOutTypeTags (?SelfOutTypeTag $ selfOutTypeTag , array $ parents ): ?SelfOutTypeTag
818
+ {
819
+ if ($ selfOutTypeTag !== null ) {
820
+ return $ selfOutTypeTag ;
821
+ }
822
+ foreach ($ parents as $ parent ) {
823
+ $ result = $ parent ->getSelfOutTag ();
824
+ if ($ result === null ) {
825
+ continue ;
826
+ }
827
+ return $ result ;
828
+ }
829
+
830
+ return null ;
831
+ }
832
+
814
833
/**
815
834
* @param array<int, self> $parents
816
835
*/
0 commit comments