Skip to content

Commit 40485e7

Browse files
authored
Fix MorphTo Model Doc Generation (#1668)
fix: ```php /** * @return MorphTo<contravariant ModelA|ModelB, $this> */ 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
1 parent ead24b1 commit 40485e7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Console/ModelsCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ public function getPropertiesFromMethods($model)
826826
$matches = [];
827827
$returnType = $this->getReturnTypeFromDocBlock($reflection);
828828
if ($returnType !== null) {
829-
preg_match('/MorphTo<(.+?)(?:,|>)/i', $returnType, $matches);
829+
preg_match('/MorphTo<(?:contravariant\s+)?(.+?)(?:,|>)/i', $returnType, $matches);
830830
}
831831

832832
// Model isn't specified because relation is polymorphic

0 commit comments

Comments
 (0)