Skip to content

Commit 8ce1ef6

Browse files
Merge branch '3.4' into 4.4
* 3.4: [Process] Fix Permission Denied error when writing sf_proc_00 lock files on Windows fix handling null as empty data No need to create an issue when creating a PR [Console] Fixes question input encoding on Windows
2 parents f56e263 + db8dd8b commit 8ce1ef6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ public function transform($value)
140140
*/
141141
public function reverseTransform($value)
142142
{
143-
if (!\is_string($value)) {
143+
if (null !== $value && !\is_string($value)) {
144144
throw new TransformationFailedException('Expected a string.');
145145
}
146146

147-
if ('' === $value) {
147+
if (null === $value || '' === $value) {
148148
return null;
149149
}
150150

Tests/Extension/Core/Type/NumberTypeTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = '10', $expectedD
130130
$this->assertSame($expectedData, $form->getData());
131131
}
132132

133+
public function testSubmitNullWithEmptyDataSetToNull()
134+
{
135+
$form = $this->factory->create(static::TESTED_TYPE, null, [
136+
'empty_data' => null,
137+
]);
138+
$form->submit(null);
139+
140+
$this->assertTrue($form->isSubmitted());
141+
$this->assertTrue($form->isSynchronized());
142+
$this->assertTrue($form->isValid());
143+
$this->assertSame('', $form->getViewData());
144+
$this->assertNull($form->getNormData());
145+
$this->assertNull($form->getData());
146+
}
147+
133148
public function testSubmitNumericInput(): void
134149
{
135150
$form = $this->factory->create(static::TESTED_TYPE, null, ['input' => 'number']);

0 commit comments

Comments
 (0)