Skip to content

Commit 9623ddf

Browse files
committed
fix(Bp4ELhAA): indirect modification of overloaded property in generated DTOs
- Updated __get to return 'values' by reference to enable direct modifications. - Ensured undefined properties return null without throwing exceptions.
2 parents 7334dca + 41e6bd6 commit 9623ddf

24 files changed

+161
-54
lines changed

src/ClientTest/src/OpenAPI/V1/DTO/ErrorResult.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ class ErrorResult implements \IteratorAggregate, \JsonSerializable
2424
*/
2525
private array $messages;
2626

27-
public function __get($name)
27+
public function &__get($name)
2828
{
29-
return $this->isInitialized($name) ? $this->{$name} : null;
29+
if ($this->isInitialized($name)) {
30+
return $this->{$name};
31+
}
32+
$null = null;
33+
return $null;
3034
}
3135

3236
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/Message.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ class Message implements \IteratorAggregate, \JsonSerializable
5656
*/
5757
private string $text;
5858

59-
public function __get($name)
59+
public function &__get($name)
6060
{
61-
return $this->isInitialized($name) ? $this->{$name} : null;
61+
if ($this->isInitialized($name)) {
62+
return $this->{$name};
63+
}
64+
$null = null;
65+
return $null;
6266
}
6367

6468
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/NestedObject.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ class NestedObject implements \IteratorAggregate, \JsonSerializable
2121
*/
2222
private string $name;
2323

24-
public function __get($name)
24+
public function &__get($name)
2525
{
26-
return $this->isInitialized($name) ? $this->{$name} : null;
26+
if ($this->isInitialized($name)) {
27+
return $this->{$name};
28+
}
29+
$null = null;
30+
return $null;
2731
}
2832

2933
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/Resource.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ class Resource implements \IteratorAggregate, \JsonSerializable
5555
*/
5656
private array $arrayField;
5757

58-
public function __get($name)
58+
public function &__get($name)
5959
{
60-
return $this->isInitialized($name) ? $this->{$name} : null;
60+
if ($this->isInitialized($name)) {
61+
return $this->{$name};
62+
}
63+
$null = null;
64+
return $null;
6165
}
6266

6367
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/ResourceGETQueryData.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ class ResourceGETQueryData implements \IteratorAggregate, \JsonSerializable
2323
*/
2424
private string $filter;
2525

26-
public function __get($name)
26+
public function &__get($name)
2727
{
28-
return $this->isInitialized($name) ? $this->{$name} : null;
28+
if ($this->isInitialized($name)) {
29+
return $this->{$name};
30+
}
31+
$null = null;
32+
return $null;
2933
}
3034

3135
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/ResourceListResult.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ class ResourceListResult implements \IteratorAggregate, \JsonSerializable
3333
*/
3434
private array $messages;
3535

36-
public function __get($name)
36+
public function &__get($name)
3737
{
38-
return $this->isInitialized($name) ? $this->{$name} : null;
38+
if ($this->isInitialized($name)) {
39+
return $this->{$name};
40+
}
41+
$null = null;
42+
return $null;
3943
}
4044

4145
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/ResourcePostRequest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ class ResourcePostRequest implements \IteratorAggregate, \JsonSerializable
2929
*/
3030
private ?string $optionalField;
3131

32-
public function __get($name)
32+
public function &__get($name)
3333
{
34-
return $this->isInitialized($name) ? $this->{$name} : null;
34+
if ($this->isInitialized($name)) {
35+
return $this->{$name};
36+
}
37+
$null = null;
38+
return $null;
3539
}
3640

3741
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/ResourceResult.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ class ResourceResult implements \IteratorAggregate, \JsonSerializable
3131
*/
3232
private array $messages;
3333

34-
public function __get($name)
34+
public function &__get($name)
3535
{
36-
return $this->isInitialized($name) ? $this->{$name} : null;
36+
if ($this->isInitialized($name)) {
37+
return $this->{$name};
38+
}
39+
$null = null;
40+
return $null;
3741
}
3842

3943
public function __set(string $name, $value): void

src/ClientTest/src/OpenAPI/V1/DTO/SuccessResult.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ class SuccessResult implements \IteratorAggregate, \JsonSerializable
3131
*/
3232
private array $messages;
3333

34-
public function __get($name)
34+
public function &__get($name)
3535
{
36-
return $this->isInitialized($name) ? $this->{$name} : null;
36+
if ($this->isInitialized($name)) {
37+
return $this->{$name};
38+
}
39+
$null = null;
40+
return $null;
3741
}
3842

3943
public function __set(string $name, $value): void

src/Test/src/OpenAPI/V1_0_1/DTO/Bla.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ class Bla implements \IteratorAggregate, \JsonSerializable
2727
*/
2828
private string $name;
2929

30-
public function __get($name)
30+
public function &__get($name)
3131
{
32-
return $this->isInitialized($name) ? $this->{$name} : null;
32+
if ($this->isInitialized($name)) {
33+
return $this->{$name};
34+
}
35+
$null = null;
36+
return $null;
3337
}
3438

3539
public function __set(string $name, $value): void

0 commit comments

Comments
 (0)