Skip to content

Commit 997d98a

Browse files
committed
removed support for key PreventMerging (BC break)
1 parent 297db99 commit 997d98a

File tree

4 files changed

+2
-63
lines changed

4 files changed

+2
-63
lines changed

src/Schema/Elements/AnyOf.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ public function normalize(mixed $value, Context $context): mixed
6464

6565
public function merge(mixed $value, mixed $base): mixed
6666
{
67-
if (is_array($value) && isset($value[Helpers::PreventMerging])) {
68-
unset($value[Helpers::PreventMerging]);
69-
return $value;
70-
}
71-
7267
return Helpers::merge($value, $base);
7368
}
7469

src/Schema/Elements/Structure.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public function getShape(): array
9494

9595
public function normalize(mixed $value, Context $context): mixed
9696
{
97-
if ($prevent = (is_array($value) && isset($value[Helpers::PreventMerging]))) {
98-
unset($value[Helpers::PreventMerging]);
99-
}
100-
10197
$value = $this->doNormalize($value, $context);
10298
if (is_object($value)) {
10399
$value = (array) $value;
@@ -112,10 +108,6 @@ public function normalize(mixed $value, Context $context): mixed
112108
array_pop($context->path);
113109
}
114110
}
115-
116-
if ($prevent) {
117-
$value[Helpers::PreventMerging] = true;
118-
}
119111
}
120112

121113
return $value;

src/Schema/Elements/Type.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ public function pattern(?string $pattern): self
112112

113113
public function normalize(mixed $value, Context $context): mixed
114114
{
115-
if ($prevent = (is_array($value) && isset($value[Helpers::PreventMerging]))) {
116-
unset($value[Helpers::PreventMerging]);
117-
}
118-
119115
$value = $this->doNormalize($value, $context);
120116
if (is_array($value) && $this->itemsValue) {
121117
$res = [];
@@ -133,18 +129,13 @@ public function normalize(mixed $value, Context $context): mixed
133129
$value = $res;
134130
}
135131

136-
if ($prevent && is_array($value)) {
137-
$value[Helpers::PreventMerging] = true;
138-
}
139-
140132
return $value;
141133
}
142134

143135

144136
public function merge(mixed $value, mixed $base): mixed
145137
{
146-
if ($this->mergeMode === MergeMode::Replace || (is_array($value) && isset($value[Helpers::PreventMerging]))) {
147-
unset($value[Helpers::PreventMerging]);
138+
if ($this->mergeMode === MergeMode::Replace) {
148139
return $value;
149140
}
150141

@@ -170,12 +161,6 @@ public function merge(mixed $value, mixed $base): mixed
170161

171162
public function complete(mixed $value, Context $context): mixed
172163
{
173-
$merge = $this->merge;
174-
if (is_array($value) && isset($value[Helpers::PreventMerging])) {
175-
unset($value[Helpers::PreventMerging]);
176-
$merge = false;
177-
}
178-
179164
if ($value === null && is_array($this->default)) {
180165
$value = []; // is unable to distinguish null from array in NEON
181166
}
@@ -187,7 +172,7 @@ public function complete(mixed $value, Context $context): mixed
187172
$isOk() && Helpers::validateRange($value, $this->range, $context, $this->type);
188173
$isOk() && $value !== null && $this->pattern !== null && Helpers::validatePattern($value, $this->pattern, $context);
189174
$isOk() && is_array($value) && $this->validateItems($value, $context);
190-
$isOk() && $merge && $value = Helpers::merge($value, $this->default);
175+
$isOk() && $this->merge && $value = Helpers::merge($value, $this->default);
191176
$isOk() && $value = $this->doTransform($value, $context);
192177
if (!$isOk()) {
193178
return null;

tests/Schema/Expect.array.phpt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -96,39 +96,6 @@ test('merging default value', function () {
9696
'arr' => ['newitem'],
9797
]),
9898
);
99-
100-
Assert::same(
101-
[
102-
'key1' => 'newval',
103-
'key3' => 'newval',
104-
'newval3',
105-
'arr' => ['newitem'],
106-
],
107-
(new Processor)->process($schema, [
108-
Helpers::PreventMerging => true,
109-
'key1' => 'newval',
110-
'key3' => 'newval',
111-
'newval3',
112-
'arr' => ['newitem'],
113-
]),
114-
);
115-
116-
Assert::same(
117-
[
118-
'key1' => 'newval',
119-
'key2' => 'val2',
120-
'val3',
121-
'arr' => ['newitem'],
122-
'key3' => 'newval',
123-
'newval3',
124-
],
125-
(new Processor)->process($schema, [
126-
'key1' => 'newval',
127-
'key3' => 'newval',
128-
'newval3',
129-
'arr' => [Helpers::PreventMerging => true, 'newitem'],
130-
]),
131-
);
13299
});
133100

134101

0 commit comments

Comments
 (0)