Skip to content

Commit

Permalink
Adjust for Reference::hasOne() strong return type (#2183)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Mar 15, 2024
1 parent 50dc785 commit b51f5df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion demos/init-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Atk4\Core\Factory;
use Atk4\Data\Field;
use Atk4\Data\Model;
use Atk4\Data\Reference;
use Atk4\Ui\Exception;
use Atk4\Ui\Form;
use Atk4\Ui\Table;
Expand Down Expand Up @@ -299,7 +300,7 @@ public function addField(string $name, $seed = []): Field
}

#[\Override]
public function hasOne(string $link, array $defaults = [])
public function hasOne(string $link, array $defaults): Reference
{
// TODO remove once HasOne reference can infer type from their model
if (!isset($defaults['type'])) {
Expand Down
6 changes: 3 additions & 3 deletions docs/multiline.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class User extends \Atk4\Data\Model
$this->addField('firstname', ['type' => 'string']);
$this->addField('lastname', ['type' => 'string']);
$this->containsMany('addresses', [Address::class, 'system' => false]);
$this->containsMany('addresses', ['model' => [Address::class], 'system' => false]);
}
}
Expand Down Expand Up @@ -81,7 +81,7 @@ class Email extends \Atk4\Data\Model
$this->addField('email_address', ['type' => 'string']);
$this->hasOne('user_id', [User::class]);
$this->hasOne('user_id', ['model' => [User::class]]);
}
}
Expand All @@ -99,7 +99,7 @@ class User extends \Atk4\Data\Model
$this->addField('firstname', ['type' => 'string']);
$this->addField('lastname', ['type' => 'string']);
$this->hasMany('Emails', [Email::class]);
$this->hasMany('Emails', ['model' => [Email::class]]);
}
}
```
Expand Down

0 comments on commit b51f5df

Please sign in to comment.