diff --git a/src/SimpleDTO.php b/src/SimpleDTO.php index fc65cb4..fb8431b 100644 --- a/src/SimpleDTO.php +++ b/src/SimpleDTO.php @@ -33,7 +33,8 @@ abstract class SimpleDTO implements BaseDTO, CastsAttributes { use DataResolver, DataTransformer; - protected array $data = []; + /** @internal */ + protected array $dtoData = []; protected array $validatedData = []; @@ -63,7 +64,7 @@ public function __construct(?array $data = null) } $this->buildAttributesData(); - $this->data = $this->buildDataForValidation($data); + $this->dtoData = $this->buildDataForValidation($data); $this->initConfig(); @@ -193,7 +194,7 @@ protected function passedValidation(): void } } - $this->data = []; + $this->dtoData = []; } protected function failedValidation(): void @@ -219,7 +220,7 @@ protected function validatedData(): array /** @var array $casts */ $casts = $this->buildCasts(); - foreach ($this->data as $key => $value) { + foreach ($this->dtoData as $key => $value) { if (in_array($key, $acceptedKeys)) { if (! array_key_exists($key, $casts)) { if ($this->requireCasting) { @@ -514,7 +515,7 @@ private function getAcceptedProperties(): array private function isforbiddenProperty(string $property): bool { return in_array($property, [ - 'data', + 'dtoData', 'validatedData', 'requireCasting', 'validator', diff --git a/src/ValidatedDTO.php b/src/ValidatedDTO.php index 0efab0c..983e84f 100644 --- a/src/ValidatedDTO.php +++ b/src/ValidatedDTO.php @@ -51,7 +51,7 @@ protected function validatedData(): array /** @var array $casts */ $casts = $this->buildCasts(); - foreach ($this->data as $key => $value) { + foreach ($this->dtoData as $key => $value) { if (in_array($key, $acceptedKeys)) { if (! array_key_exists($key, $casts)) { if ($this->requireCasting) { @@ -83,7 +83,7 @@ protected function validatedData(): array protected function isValidData(): bool { $this->validator = Validator::make( - $this->data, + $this->dtoData, $this->rulesList(), $this->messagesList(), $this->attributes()