Skip to content

Commit

Permalink
fix: use static reference for model instantiation and update return t…
Browse files Browse the repository at this point in the history
…ype annotations
  • Loading branch information
SonyPradana committed Feb 8, 2025
1 parent a48e86d commit 1018656
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/System/Database/MyModel/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public function hasOne($model, ?string $ref = null)
} else {
$table_name = $model;
$join_ref = $ref ?? $this->primery_key;
$model = new Model($this->pdo, []);
$model = new static($this->pdo, []);
}
$result = MyQuery::from($this->table_name, $this->pdo)
->select([$table_name . '.*'])
Expand Down Expand Up @@ -387,7 +387,7 @@ public function hasMany($model, ?string $ref = null)
} else {
$table_name = $model;
$join_ref = $ref ?? $this->primery_key;
$model = new Model($this->pdo, []);
$model = new static($this->pdo, []);
}
$result = MyQuery::from($this->table_name, $this->pdo)
->select([$table_name . '.*'])
Expand Down Expand Up @@ -573,7 +573,7 @@ public function offsetExists($offset): bool
* @return mixed|null
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->getter($offset, null);
}
Expand Down Expand Up @@ -679,7 +679,7 @@ public static function equal($column_name, $value, MyPDO $pdo): static
/**
* Fetch all records.
*
* @return ModelCollection<static<array-key, mixed>>
* @return ModelCollection<array-key, static>
*/
public static function all(MyPDO $pdo): ModelCollection
{
Expand Down

0 comments on commit 1018656

Please sign in to comment.