Skip to content

Commit 19034b3

Browse files
Merge pull request #91 from WendellAdriel/hotfix/data-property
Fix issue with data property
2 parents cb418e0 + 0ed6764 commit 19034b3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/SimpleDTO.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ abstract class SimpleDTO implements BaseDTO, CastsAttributes
3333
{
3434
use DataResolver, DataTransformer;
3535

36-
protected array $data = [];
36+
/** @internal */
37+
protected array $dtoData = [];
3738

3839
protected array $validatedData = [];
3940

@@ -63,7 +64,7 @@ public function __construct(?array $data = null)
6364
}
6465

6566
$this->buildAttributesData();
66-
$this->data = $this->buildDataForValidation($data);
67+
$this->dtoData = $this->buildDataForValidation($data);
6768

6869
$this->initConfig();
6970

@@ -193,7 +194,7 @@ protected function passedValidation(): void
193194
}
194195
}
195196

196-
$this->data = [];
197+
$this->dtoData = [];
197198
}
198199

199200
protected function failedValidation(): void
@@ -219,7 +220,7 @@ protected function validatedData(): array
219220
/** @var array<Castable> $casts */
220221
$casts = $this->buildCasts();
221222

222-
foreach ($this->data as $key => $value) {
223+
foreach ($this->dtoData as $key => $value) {
223224
if (in_array($key, $acceptedKeys)) {
224225
if (! array_key_exists($key, $casts)) {
225226
if ($this->requireCasting) {
@@ -514,7 +515,7 @@ private function getAcceptedProperties(): array
514515
private function isforbiddenProperty(string $property): bool
515516
{
516517
return in_array($property, [
517-
'data',
518+
'dtoData',
518519
'validatedData',
519520
'requireCasting',
520521
'validator',

src/ValidatedDTO.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function validatedData(): array
5151
/** @var array<Castable> $casts */
5252
$casts = $this->buildCasts();
5353

54-
foreach ($this->data as $key => $value) {
54+
foreach ($this->dtoData as $key => $value) {
5555
if (in_array($key, $acceptedKeys)) {
5656
if (! array_key_exists($key, $casts)) {
5757
if ($this->requireCasting) {
@@ -83,7 +83,7 @@ protected function validatedData(): array
8383
protected function isValidData(): bool
8484
{
8585
$this->validator = Validator::make(
86-
$this->data,
86+
$this->dtoData,
8787
$this->rulesList(),
8888
$this->messagesList(),
8989
$this->attributes()

0 commit comments

Comments
 (0)