Skip to content

Commit f027750

Browse files
committed
Consistently typehint model as an object
1 parent 8766f51 commit f027750

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

docs/context.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Context
3232
public ?Serializer $serializer = null;
3333

3434
// The model that is currently being serialized, updated, or deleted
35-
public mixed $model = null;
35+
public object $model = null;
3636

3737
// The field that is currently being processed
3838
public ?Field $field = null;
@@ -63,7 +63,7 @@ class Context
6363
public function resource(string $type): Resource;
6464

6565
// Get the ID for a model
66-
public function id(Resource $resource, mixed $model): string;
66+
public function id(Resource $resource, object $model): string;
6767

6868
// Get the fields for the given resource, keyed by name
6969
public function fields(Resource $resource): array;

src/Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Context
1919
public ?Endpoint $endpoint = null;
2020
public ?object $query = null;
2121
public ?Serializer $serializer = null;
22-
public mixed $model = null;
22+
public ?object $model = null;
2323
public ?Field $field = null;
2424
public ?array $include = null;
2525
public ArrayObject $documentMeta;
@@ -238,7 +238,7 @@ public function withSerializer(?Serializer $serializer): static
238238
return $new;
239239
}
240240

241-
public function withModel(mixed $model): static
241+
public function withModel(?object $model): static
242242
{
243243
$new = clone $this;
244244
$new->model = $model;
@@ -266,7 +266,7 @@ public function resourceMeta($model, array $meta): static
266266
return $this;
267267
}
268268

269-
public function forModel(array $collections, mixed $model): static
269+
public function forModel(array $collections, ?object $model): static
270270
{
271271
$new = clone $this;
272272

src/Schema/Concerns/SetsValue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function validateValue(mixed $value, callable $fail, Context $context): v
154154
/**
155155
* Set a value for this field to a model.
156156
*/
157-
public function setValue(mixed $model, mixed $value, Context $context): void
157+
public function setValue(object $model, mixed $value, Context $context): void
158158
{
159159
if ($this->setter) {
160160
($this->setter)($model, $value, $context);
@@ -169,7 +169,7 @@ public function setValue(mixed $model, mixed $value, Context $context): void
169169
/**
170170
* Save a value for this field to a model.
171171
*/
172-
public function saveValue(mixed $model, mixed $value, Context $context): void
172+
public function saveValue(object $model, mixed $value, Context $context): void
173173
{
174174
if ($this->saver) {
175175
($this->saver)($model, $value, $context);

src/Schema/Field/BooleanDateTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public function __construct(string $name)
1414
$this->type(Boolean::make());
1515
}
1616

17-
public function setValue(mixed $model, mixed $value, Context $context): void
17+
public function setValue(object $model, mixed $value, Context $context): void
1818
{
1919
parent::setValue($model, $value ? new \DateTime() : null, $context);
2020
}
2121

22-
public function saveValue(mixed $model, mixed $value, Context $context): void
22+
public function saveValue(object $model, mixed $value, Context $context): void
2323
{
2424
parent::saveValue($model, $value ? new \DateTime() : null, $context);
2525
}

0 commit comments

Comments
 (0)