From b8445eabc33c468cbe7eae44af2ec6d0080c9357 Mon Sep 17 00:00:00 2001 From: Lorenzo Losa Date: Tue, 17 Dec 2024 16:50:53 +0000 Subject: [PATCH] align type definitions to Laravel --- src/HasChildren.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/HasChildren.php b/src/HasChildren.php index aa5c31e..cda260c 100644 --- a/src/HasChildren.php +++ b/src/HasChildren.php @@ -25,7 +25,7 @@ trait HasChildren * Register a model event with the dispatcher. * * @param string $event - * @param Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|callable|array|class-string $callback */ protected static function registerModelEvent($event, $callback): void { @@ -124,10 +124,13 @@ public function newFromBuilder($attributes = [], $connection = null): self /** * Define an inverse one-to-one or many relationship. * - * @param string $related + * @template TRelatedModel of \Illuminate\Database\Eloquent\Model + * + * @param class-string $related * @param string|null $foreignKey * @param string|null $ownerKey * @param string|null $relation + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null): BelongsTo { @@ -147,9 +150,12 @@ public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relat /** * Define a one-to-many relationship. * - * @param string $related + * @template TRelatedModel of \Illuminate\Database\Eloquent\Model + * + * @param class-string $related * @param string|null $foreignKey * @param string|null $localKey + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function hasMany($related, $foreignKey = null, $localKey = null): HasMany { @@ -159,13 +165,16 @@ public function hasMany($related, $foreignKey = null, $localKey = null): HasMany /** * Define a many-to-many relationship. * - * @param string $related - * @param string|null $table + * @template TRelatedModel of \Illuminate\Database\Eloquent\Model + * + * @param class-string $related + * @param string|class-string<\Illuminate\Database\Eloquent\Model>|null $table * @param string|null $foreignPivotKey * @param string|null $relatedPivotKey * @param string|null $parentKey * @param string|null $relatedKey * @param string|null $relation + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function belongsToMany( $related, $table = null,