From 565cf2b158dc60283f3ca1daadd7b9317281d8be Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 22 Sep 2024 00:25:49 +0200 Subject: [PATCH] Update to laravel-data 4.0 --- src/Casters/CarbonCast.php | 3 ++- src/Casters/GroupCast.php | 3 ++- src/Casters/NullValueCast.php | 3 ++- src/Casters/StringCast.php | 3 ++- src/Transformers/CarbonTransformer.php | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Casters/CarbonCast.php b/src/Casters/CarbonCast.php index 812d3b5..e9eedad 100644 --- a/src/Casters/CarbonCast.php +++ b/src/Casters/CarbonCast.php @@ -7,6 +7,7 @@ use Spatie\LaravelData\Casts\Cast; use Spatie\LaravelData\Casts\DateTimeInterfaceCast; use Spatie\LaravelData\Casts\Uncastable; use Spatie\LaravelData\Exceptions\CannotCastDate; +use Spatie\LaravelData\Support\Creation\CreationContext; use Spatie\LaravelData\Support\DataProperty; class CarbonCast implements Cast @@ -19,7 +20,7 @@ class CarbonCast implements Cast /** * @param array $context */ - public function cast(DataProperty $property, mixed $value, array $context): DateTimeInterface|Uncastable|null + public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null { if ($property->type->isNullable && !$value) { return null; diff --git a/src/Casters/GroupCast.php b/src/Casters/GroupCast.php index 883c1be..fad0a19 100644 --- a/src/Casters/GroupCast.php +++ b/src/Casters/GroupCast.php @@ -3,6 +3,7 @@ namespace Zoomyboy\LaravelNami\Casters; use Spatie\LaravelData\Casts\Cast; +use Spatie\LaravelData\Support\Creation\CreationContext; use Spatie\LaravelData\Support\DataProperty; class GroupCast implements Cast @@ -14,7 +15,7 @@ class GroupCast implements Cast /** * @param array $context */ - public function cast(DataProperty $property, mixed $value, array $context): ?string + public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string { if ($property->type->isNullable && !$value) { return null; diff --git a/src/Casters/NullValueCast.php b/src/Casters/NullValueCast.php index 265d36b..4cc5682 100644 --- a/src/Casters/NullValueCast.php +++ b/src/Casters/NullValueCast.php @@ -5,6 +5,7 @@ namespace Zoomyboy\LaravelNami\Casters; use DateTimeInterface; use Spatie\LaravelData\Casts\Cast; use Spatie\LaravelData\Casts\Uncastable; +use Spatie\LaravelData\Support\Creation\CreationContext; use Spatie\LaravelData\Support\DataProperty; class NullValueCast implements Cast @@ -17,7 +18,7 @@ class NullValueCast implements Cast /** * @param array $context */ - public function cast(DataProperty $property, mixed $value, array $context): DateTimeInterface|Uncastable|null|int + public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null|int { if ($this->id === $value) { return null; diff --git a/src/Casters/StringCast.php b/src/Casters/StringCast.php index dcaa6de..24bcb8a 100644 --- a/src/Casters/StringCast.php +++ b/src/Casters/StringCast.php @@ -3,6 +3,7 @@ namespace Zoomyboy\LaravelNami\Casters; use Spatie\LaravelData\Casts\Cast; +use Spatie\LaravelData\Support\Creation\CreationContext; use Spatie\LaravelData\Support\DataProperty; class StringCast implements Cast @@ -14,7 +15,7 @@ class StringCast implements Cast /** * @param array $context */ - public function cast(DataProperty $property, mixed $value, array $context): ?string + public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string { if ($property->type->isNullable && !$value) { return null; diff --git a/src/Transformers/CarbonTransformer.php b/src/Transformers/CarbonTransformer.php index 395001d..5869bee 100644 --- a/src/Transformers/CarbonTransformer.php +++ b/src/Transformers/CarbonTransformer.php @@ -3,6 +3,7 @@ namespace Zoomyboy\LaravelNami\Transformers; use Spatie\LaravelData\Support\DataProperty; +use Spatie\LaravelData\Support\Transformation\TransformationContext; use Spatie\LaravelData\Transformers\Transformer; class CarbonTransformer implements Transformer @@ -12,7 +13,7 @@ class CarbonTransformer implements Transformer ) { } - public function transform(DataProperty $property, mixed $value): mixed + public function transform(DataProperty $property, mixed $value, TransformationContext $context): mixed { if (is_null($value)) { return null;