Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix relation docblocks #184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading