diff --git a/pint.json b/pint.json index b59230b0..19f1ab5e 100644 --- a/pint.json +++ b/pint.json @@ -84,6 +84,7 @@ "property": "none", "trait_import": "none" } - } + }, + "new_with_parentheses": true } } diff --git a/src/Casts/MachineCast.php b/src/Casts/MachineCast.php index 0a77bc14..a2443710 100644 --- a/src/Casts/MachineCast.php +++ b/src/Casts/MachineCast.php @@ -54,8 +54,12 @@ public function get( * @param TSet|null $value * @param array $attributes */ - public function set(Model $model, string $key, mixed $value, array $attributes): string + public function set(Model $model, string $key, mixed $value, array $attributes): ?string { + if ($value === null) { + return null; + } + if (is_string($value)) { return $value; } diff --git a/tests/ActionTest.php b/tests/ActionTest.php index 82655e01..0719124e 100644 --- a/tests/ActionTest.php +++ b/tests/ActionTest.php @@ -91,7 +91,7 @@ // 1. Arrange $value = random_int(10, 20); - $multipleWithItselfAction = new class extends ResultBehavior { + $multipleWithItselfAction = new class() extends ResultBehavior { public function __invoke(EventBehavior $event): int { return $event->payload['value'] * $event->payload['value'];