Skip to content

Commit 4c37bb9

Browse files
committed
Container: getValues(true) is deprecated (BC break)
1 parent 8997b0d commit 4c37bb9

File tree

7 files changed

+28
-24
lines changed

7 files changed

+28
-24
lines changed

src/Forms/Container.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ public function getValues(string|object|bool|null $returnType = null, ?array $co
117117
}
118118
}
119119

120-
$returnType = $returnType === true ? self::Array : $returnType;
120+
if ($returnType === true) {
121+
trigger_error(static::class . '::' . __FUNCTION__ . "(true) is deprecated, use getValues('array').", E_USER_DEPRECATED);
122+
$returnType = self::Array;
123+
}
124+
121125
return $this->getUnsafeValues($returnType, $controls);
122126
}
123127

tests/Forms/Container.values.array.phpt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ test('setDefaults() + array', function () {
6464
'city' => 'zzz',
6565
],
6666
],
67-
], $form->getValues(true));
67+
], $form->getValues('array'));
6868
});
6969

7070

71-
test('submitted form + getValues(true)', function () {
71+
test('submitted form + getValues(array)', function () {
7272
$_SERVER['REQUEST_METHOD'] = 'POST';
7373

7474
$form = createForm();
@@ -82,7 +82,7 @@ test('submitted form + getValues(true)', function () {
8282
'city' => 'sent city',
8383
],
8484
],
85-
], $form->getValues(true));
85+
], $form->getValues('array'));
8686
});
8787

8888

@@ -104,7 +104,7 @@ test('submitted form + reset()', function () {
104104
'city' => '',
105105
],
106106
],
107-
], $form->getValues(true));
107+
], $form->getValues('array'));
108108
});
109109

110110

@@ -130,7 +130,7 @@ test('setValues() + array', function () {
130130
'city' => 'sent city',
131131
],
132132
],
133-
], $form->getValues(true));
133+
], $form->getValues('array'));
134134

135135
// erase
136136
$form->setValues([
@@ -149,7 +149,7 @@ test('setValues() + array', function () {
149149
'city' => '',
150150
],
151151
],
152-
], $form->getValues(true));
152+
], $form->getValues('array'));
153153
});
154154

155155

@@ -261,7 +261,7 @@ test('onSuccess test', function () {
261261
});
262262

263263

264-
test('submitted form + setValidationScope() + getValues(true)', function () {
264+
test('submitted form + setValidationScope() + getValues(array)', function () {
265265
$_SERVER['REQUEST_METHOD'] = 'POST';
266266
$_POST['send'] = '';
267267

@@ -275,11 +275,11 @@ test('submitted form + setValidationScope() + getValues(true)', function () {
275275
'age' => 999,
276276
'second' => [],
277277
],
278-
], $form->getValues(true));
278+
], $form->getValues('array'));
279279
});
280280

281281

282-
test('submitted form + setValidationScope() + getValues(true)', function () {
282+
test('submitted form + setValidationScope() + getValues(array)', function () {
283283
$_SERVER['REQUEST_METHOD'] = 'POST';
284284
$_POST['send'] = '';
285285

@@ -294,5 +294,5 @@ test('submitted form + setValidationScope() + getValues(true)', function () {
294294
'city' => 'sent city',
295295
],
296296
],
297-
], $form->getValues(true));
297+
], $form->getValues('array'));
298298
});

tests/Forms/Container.values.mapping.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test('setDefaults() + object', function () {
9999
'city' => 'zzz',
100100
],
101101
],
102-
], $form->getValues(true));
102+
], $form->getValues('array'));
103103
});
104104

105105

@@ -242,7 +242,7 @@ test('getValues(...arguments...)', function () {
242242
'city' => '',
243243
]),
244244
]),
245-
], $form->getValues(true));
245+
], $form->getValues('array'));
246246
});
247247

248248

@@ -335,7 +335,7 @@ test('getValues() + object', function () {
335335
});
336336

337337

338-
test('submitted form + setValidationScope() + getValues(true)', function () {
338+
test('submitted form + setValidationScope() + getValues()', function () {
339339
$_SERVER['REQUEST_METHOD'] = 'POST';
340340
$_POST['send'] = '';
341341

@@ -353,7 +353,7 @@ test('submitted form + setValidationScope() + getValues(true)', function () {
353353
});
354354

355355

356-
test('submitted form + setValidationScope() + getValues(true)', function () {
356+
test('submitted form + setValidationScope() + getValues()', function () {
357357
$_SERVER['REQUEST_METHOD'] = 'POST';
358358
$_POST['send'] = '';
359359

tests/Forms/Forms.getHttpData.get.2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ test('', function () {
2929

3030
Assert::truthy($form->isSubmitted());
3131
Assert::same(['item'], $form->getHttpData());
32-
Assert::same([], $form->getValues(true));
32+
Assert::same([], $form->getValues('array'));
3333
});

tests/Forms/Forms.getHttpData.get.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test('', function () {
2828
Assert::false($form->isSubmitted());
2929
Assert::false($form->isSuccess());
3030
Assert::same([], $form->getHttpData());
31-
Assert::same([], $form->getValues(true));
31+
Assert::same([], $form->getValues('array'));
3232
});
3333

3434

@@ -38,7 +38,7 @@ test('', function () {
3838

3939
Assert::false($form->isSubmitted());
4040
Assert::same([], $form->getHttpData());
41-
Assert::same([], $form->getValues(true));
41+
Assert::same([], $form->getValues('array'));
4242
});
4343

4444

@@ -53,6 +53,6 @@ test('', function () {
5353

5454
Assert::truthy($form->isSubmitted());
5555
Assert::same([Form::TRACKER_ID => $name], $form->getHttpData());
56-
Assert::same([], $form->getValues(true));
56+
Assert::same([], $form->getValues('array'));
5757
Assert::same($name, $form[Form::TRACKER_ID]->getValue());
5858
});

tests/Forms/Forms.getHttpData.post.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('', function () {
2929
Assert::truthy($form->isSubmitted());
3030
Assert::true($form->isSuccess());
3131
Assert::same([], $form->getHttpData());
32-
Assert::same([], $form->getValues(true));
32+
Assert::same([], $form->getValues('array'));
3333
});
3434

3535

@@ -42,7 +42,7 @@ test('', function () {
4242
Assert::false($form->isSubmitted());
4343
Assert::false($form->isSuccess());
4444
Assert::same([], $form->getHttpData());
45-
Assert::same([], $form->getValues(true));
45+
Assert::same([], $form->getValues('array'));
4646
});
4747

4848

@@ -54,7 +54,7 @@ test('', function () {
5454
Assert::false($form->isSubmitted());
5555
Assert::false($form->isSuccess());
5656
Assert::same([], $form->getHttpData());
57-
Assert::same([], $form->getValues(true));
57+
Assert::same([], $form->getValues('array'));
5858
});
5959

6060

@@ -67,7 +67,7 @@ test('', function () {
6767

6868
Assert::truthy($form->isSubmitted());
6969
Assert::same([Form::TRACKER_ID => $name], $form->getHttpData());
70-
Assert::same([], $form->getValues(true));
70+
Assert::same([], $form->getValues('array'));
7171
Assert::same($name, $form[Form::TRACKER_ID]->getValue());
7272
});
7373

tests/Forms/Forms.omittedValue.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $form->addText('input');
2020
$form->addText('omittedInput')
2121
->setOmitted();
2222

23-
Assert::same(['input' => ''], $form->getValues(true));
23+
Assert::same(['input' => ''], $form->getValues('array'));
2424

2525

2626
Assert::true((new TextInput)->setDisabled()->isOmitted());

0 commit comments

Comments
 (0)