From b34caae0b59c6645dc7fa7100856bfa896482170 Mon Sep 17 00:00:00 2001 From: konovalexander Date: Wed, 1 Nov 2023 10:43:10 +0500 Subject: [PATCH] Add generic type for WithData trait --- src/WithData.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/WithData.php b/src/WithData.php index 334ee2c96..9b4477924 100644 --- a/src/WithData.php +++ b/src/WithData.php @@ -3,12 +3,17 @@ namespace Spatie\LaravelData; use Spatie\LaravelData\Contracts\BaseData; -use Spatie\LaravelData\Contracts\DataObject; use Spatie\LaravelData\Exceptions\InvalidDataClass; +/** + * @template T + */ trait WithData { - public function getData(): DataObject + /** + * @return T + */ + public function getData() { $dataClass = match (true) { /** @psalm-suppress UndefinedThisPropertyFetch */