Skip to content

Commit

Permalink
Merge pull request #184 from chatloop/chore/fixing-relation-docblocks
Browse files Browse the repository at this point in the history
chore: fix relation docblocks
  • Loading branch information
topclaudy authored Jan 9, 2025
2 parents 0e83d58 + 3896478 commit 63fcb66
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 33 deletions.
73 changes: 44 additions & 29 deletions src/Database/Eloquent/Concerns/HasRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ public function getQualifiedKeyName()
/**
* Define a one-to-one relationship.
*
* @param string $related
* @param string|array|null $foreignKey
* @param string|array|null $localKey
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasOne
* @param class-string<TRelatedModel> $related
* @param string|array|null $foreignKey
* @param string|array|null $localKey
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasOne<TRelatedModel, $this>
*/
public function hasOne($related, $foreignKey = null, $localKey = null)
{
Expand Down Expand Up @@ -74,12 +76,15 @@ public function hasOne($related, $foreignKey = null, $localKey = null)
/**
* Instantiate a new HasOne relationship.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param string|array $foreignKey
* @param string|array $localKey
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TDeclaringModel of \Illuminate\Database\Eloquent\Model
*
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param TDeclaringModel $parent
* @param string|array $foreignKey
* @param string|array $localKey
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasOne
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasOne<TRelatedModel, TDeclaringModel>
*/
protected function newHasOne(Builder $query, Model $parent, $foreignKey, $localKey)
{
Expand All @@ -104,11 +109,13 @@ private function validateRelatedModel($related)
/**
* Define a one-to-many relationship.
*
* @param string $related
* @param string|array|null $foreignKey
* @param string|array|null $localKey
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
*
* @param class-string<TRelatedModel> $related
* @param string|array|null $foreignKey
* @param string|array|null $localKey
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany<TRelatedModel, $this>
*/
public function hasMany($related, $foreignKey = null, $localKey = null)
{
Expand Down Expand Up @@ -138,12 +145,15 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
/**
* Instantiate a new HasMany relationship.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param string|array $foreignKey
* @param string|array $localKey
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TDeclaringModel of \Illuminate\Database\Eloquent\Model
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param TDeclaringModel $parent
* @param string|array $foreignKey
* @param string|array $localKey
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany<TRelatedModel, TDeclaringModel>
*/
protected function newHasMany(Builder $query, Model $parent, $foreignKey, $localKey)
{
Expand All @@ -153,12 +163,14 @@ protected function newHasMany(Builder $query, Model $parent, $foreignKey, $local
/**
* Define an inverse one-to-one or many relationship.
*
* @param string $related
* @param string|array|null $foreignKey
* @param string|array|null $ownerKey
* @param string $relation
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
*
* @param class-string<TRelatedModel> $related
* @param string|array|null $foreignKey
* @param string|array|null $ownerKey
* @param string $relation
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo
* @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo<TRelatedModel, $this>
*/
public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null)
{
Expand Down Expand Up @@ -193,13 +205,16 @@ public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relat
/**
* Instantiate a new BelongsTo relationship.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $child
* @param string|array $foreignKey
* @param string|array $ownerKey
* @param string $relation
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TDeclaringModel of \Illuminate\Database\Eloquent\Model
*
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param TDeclaringModel $child
* @param string|array $foreignKey
* @param string|array $ownerKey
* @param string $relation
*
* @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo
* @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo<TRelatedModel, TDeclaringModel>
*/
protected function newBelongsTo(Builder $query, Model $child, $foreignKey, $ownerKey, $relation)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

/**
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TChildModel of \Illuminate\Database\Eloquent\Model
* @template TDeclaringModel of \Illuminate\Database\Eloquent\Model
*
* @extends BaseBelongsTo<TRelatedModel,TChildModel>
* @extends BaseBelongsTo<TRelatedModel,TDeclaringModel, TRelatedModel>
*/
class BelongsTo extends BaseBelongsTo
{
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Eloquent/Relations/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

/**
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TDeclaringModel of \Illuminate\Database\Eloquent\Model
*
* @extends BaseHasMany<TRelatedModel>
* @extends BaseHasMany<TRelatedModel, TDeclaringModel>
*/
class HasMany extends BaseHasMany
{
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Eloquent/Relations/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

/**
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TDeclaringModel of \Illuminate\Database\Eloquent\Model
*
* @extends BaseHasOne<TRelatedModel>
* @extends BaseHasOne<TRelatedModel, TDeclaringModel>
*/
class HasOne extends BaseHasOne
{
Expand Down

0 comments on commit 63fcb66

Please sign in to comment.