Skip to content

Commit

Permalink
assert Model type in Reference::getTheirFieldName
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed May 27, 2022
1 parent dc7053c commit 53e9746
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ final protected function getOurFieldValue(Model $ourEntity)

public function getTheirFieldName(): string
{
return $this->their_field ?? $this->model->id_field;
return $this->their_field ?? Model::assertInstanceOf($this->model)->id_field;
}

protected function onHookToOurModel(Model $model, string $spot, \Closure $fx, array $args = [], int $priority = 5): int
Expand Down
2 changes: 1 addition & 1 deletion src/Reference/HasOneSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function ref(Model $ourModel, array $defaults = []): Model
$theirModel = parent::ref($ourModel, $defaults);
$ourModel = $this->getOurModel($ourModel);

$theirFieldName = $this->their_field ?? $theirModel->id_field; // TODO why not $this->getTheirFieldName() ?
$theirFieldName = $this->their_field ?? $theirModel->id_field; // TODO $this->getTheirFieldName() seems wrong

// At this point the reference
// if our_field is the id_field and is being used in the reference
Expand Down

0 comments on commit 53e9746

Please sign in to comment.