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
This commit is contained in:
yparitcher
2025-02-04 17:49:42 +01:00
committed by GitHub
parent ead24b10f6
commit 40485e7350
+1 -1
View File
@@ -826,7 +826,7 @@ class ModelsCommand extends Command
$matches = []; $matches = [];
$returnType = $this->getReturnTypeFromDocBlock($reflection); $returnType = $this->getReturnTypeFromDocBlock($reflection);
if ($returnType !== null) { 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 // Model isn't specified because relation is polymorphic