Skip to content

Commit c1b7373

Browse files
committed
allowing old map-style construction
1 parent 50e6268 commit c1b7373

19 files changed

Lines changed: 163 additions & 50 deletions

src/ACL/ACLAuthMethod.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ACLAuthMethod extends AbstractModel
3939
public string $Namespace;
4040

4141
public function __construct(
42+
array $data = [], // Deprecated, will be removed.
4243
string $ID = '',
4344
string $Name = '',
4445
string $Type = '',
@@ -51,6 +52,10 @@ public function __construct(
5152
iterable $NamespaceRules = [],
5253
string $Namespace = ''
5354
) {
55+
if ([] !== $data) {
56+
$this->jsonUnserialize((object)$data, $this);
57+
return;
58+
}
5459
$this->ID = $ID;
5560
$this->Name = $Name;
5661
$this->Type = $Type;
@@ -202,9 +207,9 @@ public function setNamespace(string $Namespace): self
202207
return $this;
203208
}
204209

205-
public static function jsonUnserialize(\stdClass $decoded): self
210+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
206211
{
207-
$n = new static();
212+
$n = $into ?? new static();
208213
foreach ($decoded as $k => $v) {
209214
switch ($k) {
210215
case 'MaxTokenTTL':

src/ACL/ACLAuthMethodListEntry.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ACLAuthMethodListEntry extends AbstractModel
4141
public string $Namespace;
4242

4343
public function __construct(
44+
array $data = [], // Deprecated, will be removed.
4445
string $Name = '',
4546
string $Type = '',
4647
string $DisplayName = '',
@@ -51,6 +52,10 @@ public function __construct(
5152
int $ModifyIndex = 0,
5253
string $Namespace = ''
5354
) {
55+
if ([] !== $data) {
56+
$this->jsonUnserialize((object)$data, $this);
57+
return;
58+
}
5459
$this->Name = $Name;
5560
$this->Type = $Type;
5661
$this->DisplayName = $DisplayName;
@@ -174,9 +179,9 @@ public function setNamespace(string $Namespace): self
174179
return $this;
175180
}
176181

177-
public static function jsonUnserialize(\stdClass $decoded): self
182+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
178183
{
179-
$n = new static();
184+
$n = $into ?? new static();
180185
foreach ($decoded as $k => $v) {
181186
if (null === $v) {
182187
continue;

src/ACL/ACLAuthMethodNamespaceRule.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ class ACLAuthMethodNamespaceRule extends AbstractModel
2727
public string $Selector;
2828
public string $BindNamespace;
2929

30-
public function __construct(string $Selector = '', string $BindNamespace = '')
31-
{
30+
public function __construct(
31+
array $data = [], // Deprecated, will be removed.
32+
string $Selector = '',
33+
string $BindNamespace = '',
34+
) {
35+
if ([] !== $data) {
36+
$this->jsonUnserialize((object)$data, $this);
37+
return;
38+
}
3239
$this->Selector = $Selector;
3340
$this->BindNamespace = $BindNamespace;
3441
}
@@ -55,9 +62,9 @@ public function setBindNamespace(string $BindNamespace): self
5562
return $this;
5663
}
5764

58-
public static function jsonUnserialize(\stdClass $decoded): self
65+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
5966
{
60-
$n = new static();
67+
$n = $into ?? new static();
6168
foreach ($decoded as $k => $v) {
6269
$n->{$k} = $v;
6370
}

src/ACL/ACLBindingRule.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ACLBindingRule extends AbstractModel
3535
public string $Namespace;
3636

3737
public function __construct(
38+
array $data = [], // Deprecated, will be removed.
3839
string $ID = '',
3940
string $Description = '',
4041
string $AuthMethod = '',
@@ -45,6 +46,10 @@ public function __construct(
4546
int $ModifyIndex = 0,
4647
string $Namespace = ''
4748
) {
49+
if ([] !== $data) {
50+
$this->jsonUnserialize((object)$data, $this);
51+
return;
52+
}
4853
$this->ID = $ID;
4954
$this->Description = $Description;
5055
$this->AuthMethod = $AuthMethod;
@@ -155,9 +160,9 @@ public function setNamespace(string $Namespace): self
155160
return $this;
156161
}
157162

158-
public static function jsonUnserialize(\stdClass $decoded): self
163+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
159164
{
160-
$n = new static();
165+
$n = $into ?? new static();
161166
foreach ($decoded as $k => $v) {
162167
$n->{$k} = $v;
163168
}

src/ACL/ACLEntry.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@ class ACLEntry extends AbstractModel
3232
public string $Rules;
3333

3434
public function __construct(
35+
array $data = [], // Deprecated, will be removed.
3536
int $CreateIndex = 0,
3637
int $ModifyIndex = 0,
3738
string $ID = '',
3839
string $Name = '',
3940
string $Type = '',
4041
string $Rules = ''
4142
) {
43+
if ([] !== $data) {
44+
$this->jsonUnserialize((object)$data, $this);
45+
return;
46+
}
4247
$this->CreateIndex = $CreateIndex;
4348
$this->ModifyIndex = $ModifyIndex;
4449
$this->ID = $ID;
@@ -113,9 +118,9 @@ public function setRules(string $rules): self
113118
return $this;
114119
}
115120

116-
public static function jsonUnserialize(\stdClass $decoded): self
121+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
117122
{
118-
$n = new static();
123+
$n = $into ?? new static();
119124
foreach ($decoded as $k => $v) {
120125
$n->{$k} = $v;
121126
}

src/ACL/ACLLink.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ class ACLLink extends AbstractModel
2727
public string $ID;
2828
public string $Name;
2929

30-
public function __construct(string $ID = '', string $Name = '')
31-
{
30+
public function __construct(
31+
array $data = [], // Deprecated, will be removed.
32+
string $ID = '',
33+
string $Name = '',
34+
) {
35+
if ([] !== $data) {
36+
$this->jsonUnserialize((object)$data, $this);
37+
return;
38+
}
3239
$this->ID = $ID;
3340
$this->Name = $Name;
3441
}
@@ -55,9 +62,9 @@ public function setName(string $Name): self
5562
return $this;
5663
}
5764

58-
public static function jsonUnserialize(\stdClass $decoded): self
65+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
5966
{
60-
$n = new static();
67+
$n = $into ?? new static();
6168
foreach ($decoded as $k => $v) {
6269
$n->{$k} = $v;
6370
}

src/ACL/ACLLoginParams.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,16 @@ class ACLLoginParams extends AbstractModel
2828
public string $BearerToken;
2929
public null|array $Meta;
3030

31-
public function __construct(string $AuthMethod = '', string $BearerToken = '', null|array|\stdClass $Meta = null)
32-
{
31+
public function __construct(
32+
array $data = [], // Deprecated, will be removed.
33+
string $AuthMethod = '',
34+
string $BearerToken = '',
35+
null|array|\stdClass $Meta = null,
36+
) {
37+
if ([] !== $data) {
38+
$this->jsonUnserialize((object)$data, $this);
39+
return;
40+
}
3341
$this->AuthMethod = $AuthMethod;
3442
$this->BearerToken = $BearerToken;
3543
$this->setMeta($Meta);
@@ -71,9 +79,9 @@ public function setMeta(null|array|\stdClass $Meta): self
7179
return $this;
7280
}
7381

74-
public static function jsonUnserialize(\stdClass $decoded): self
82+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
7583
{
76-
$n = new static();
84+
$n = $into ?? new static();
7785
foreach ($decoded as $k => $v) {
7886
if ('Meta' === $k) {
7987
$n->setMeta($v);

src/ACL/ACLNodeIdentity.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ class ACLNodeIdentity extends AbstractModel
2727
public string $NodeName;
2828
public string $Datacenter;
2929

30-
public function __construct(string $NodeName = '', string $Datacenter = '')
31-
{
30+
public function __construct(
31+
array $data = [], // Deprecated, will be removed.
32+
string $NodeName = '',
33+
string $Datacenter = ''
34+
) {
35+
if ([] !== $data) {
36+
$this->jsonUnserialize((object)$data, $this);
37+
return;
38+
}
3239
$this->NodeName = $NodeName;
3340
$this->Datacenter = $Datacenter;
3441
}
@@ -43,9 +50,9 @@ public function getDatacenter(): string
4350
return $this->Datacenter;
4451
}
4552

46-
public static function jsonUnserialize(\stdClass $decoded): self
53+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
4754
{
48-
$n = new static();
55+
$n = $into ?? new static();
4956
foreach ($decoded as $k => $v) {
5057
$n->{$k} = $v;
5158
}

src/ACL/ACLOIDCAuthURLParams.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ class ACLOIDCAuthURLParams extends AbstractModel
3030
public null|array $Meta;
3131

3232
public function __construct(
33+
array $data = [], // Deprecated, will be removed.
3334
string $AuthMethod = '',
3435
string $RedirectURI = '',
3536
string $ClientNonce = '',
3637
null|array|\stdClass $Meta = null
3738
) {
39+
if ([] !== $data) {
40+
$this->jsonUnserialize((object)$data, $this);
41+
return;
42+
}
3843
$this->AuthMethod = $AuthMethod;
3944
$this->RedirectURI = $RedirectURI;
4045
$this->ClientNonce = $ClientNonce;
@@ -88,9 +93,10 @@ public function setMeta(null|array|\stdClass $Meta): self
8893
return $this;
8994
}
9095

91-
public static function jsonUnserialize(\stdClass $decoded): self
96+
97+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
9298
{
93-
$n = new static();
99+
$n = $into ?? new static();
94100
foreach ($decoded as $k => $v) {
95101
if ('Meta' === $k) {
96102
$n->setMeta($v);

src/ACL/ACLOIDCCallbackParams.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ class ACLOIDCCallbackParams extends AbstractModel
3030
public string $ClientNonce;
3131

3232
public function __construct(
33+
array $data = [], // Deprecated, will be removed.
3334
string $AuthMethod = '',
3435
string $State = '',
3536
string $Code = '',
3637
string $ClientNonce = '',
3738
) {
39+
if ([] !== $data) {
40+
$this->jsonUnserialize((object)$data, $this);
41+
return;
42+
}
3843
$this->AuthMethod = $AuthMethod;
3944
$this->State = $State;
4045
$this->Code = $Code;
@@ -85,9 +90,9 @@ public function setClientNonce(string $ClientNonce): self
8590
return $this;
8691
}
8792

88-
public static function jsonUnserialize(\stdClass $decoded): self
93+
public static function jsonUnserialize(\stdClass $decoded, null|self $into = null): self
8994
{
90-
$n = new static();
95+
$n = $into ?? new static();
9196
foreach ($decoded as $k => $v) {
9297
$n->{$k} = $v;
9398
}

0 commit comments

Comments
 (0)