From 40485e73509cdf190cb29eb01ea02fbebeb5250c Mon Sep 17 00:00:00 2001 From: yparitcher Date: Tue, 4 Feb 2025 11:49:42 -0500 Subject: [PATCH] Fix MorphTo Model Doc Generation (#1668) fix: ```php /** * @return MorphTo */ public function reminderable(): MorphTo { return $this->morphTo(__FUNCTION__, 'entity', 'entity_id'); } ``` From: ```php * @property-read contravariant ModelA|ModelB $reminderable ``` To: ```php * @property-read ModelA|ModelB $reminderable ``` Fixes: #1667 --- src/Console/ModelsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 095fab6..395cf9d 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -826,7 +826,7 @@ class ModelsCommand extends Command $matches = []; $returnType = $this->getReturnTypeFromDocBlock($reflection); if ($returnType !== null) { - preg_match('/MorphTo<(.+?)(?:,|>)/i', $returnType, $matches); + preg_match('/MorphTo<(?:contravariant\s+)?(.+?)(?:,|>)/i', $returnType, $matches); } // Model isn't specified because relation is polymorphic