Skip to content

Commit 66fb803

Browse files
string is the preferred value type for TextType
1 parent 6041dfe commit 66fb803

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/Symfony/Component/Form/Extension/Core/Type/TextType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ public function transform($data)
6262
*/
6363
public function reverseTransform($data)
6464
{
65-
return null === $data ? '' : $data;
65+
return $data ?? '';
6666
}
6767
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/ColorTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function validationShouldFailProvider()
8282
];
8383
}
8484

85-
public function testSubmitNull($expected = null, $norm = null, $view = null)
85+
public function testSubmitNull($expected = '', $norm = '', $view = '')
8686
{
8787
parent::testSubmitNull($expected, $norm, '');
8888
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testNotTrimmed()
4747
$this->assertSame(' pAs5w0rd ', $form->getData());
4848
}
4949

50-
public function testSubmitNull($expected = null, $norm = null, $view = null)
50+
public function testSubmitNull($expected = '', $norm = '', $view = '')
5151
{
5252
parent::testSubmitNull($expected, $norm, '');
5353
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/TextTypeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ class TextTypeTest extends BaseTypeTest
1515
{
1616
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\TextType';
1717

18-
public function testSubmitNull($expected = null, $norm = null, $view = null)
18+
public function testSubmitNull($expected = '', $norm = '', $view = '')
1919
{
2020
parent::testSubmitNull($expected, $norm, '');
2121
}
2222

2323
public function testSubmitNullReturnsNullWithEmptyDataAsString()
2424
{
2525
$form = $this->factory->create(static::TESTED_TYPE, 'name', [
26-
'empty_data' => '',
26+
'empty_data' => null,
2727
]);
2828

2929
$form->submit(null);
30-
$this->assertSame('', $form->getData());
31-
$this->assertSame('', $form->getNormData());
30+
$this->assertNull($form->getData());
31+
$this->assertNull($form->getNormData());
3232
$this->assertSame('', $form->getViewData());
3333
}
3434

3535
public function provideZeros()
3636
{
3737
return [
38-
[0, '0'],
38+
[0, 0],
3939
['0', '0'],
4040
['00000', '00000'],
4141
];

src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testSubmitAddsNoDefaultProtocolIfEmpty()
4747

4848
$form->submit('');
4949

50-
$this->assertNull($form->getData());
50+
$this->assertSame('', $form->getData());
5151
$this->assertSame('', $form->getViewData());
5252
}
5353

@@ -59,7 +59,7 @@ public function testSubmitAddsNoDefaultProtocolIfNull()
5959

6060
$form->submit(null);
6161

62-
$this->assertNull($form->getData());
62+
$this->assertSame('', $form->getData());
6363
$this->assertSame('', $form->getViewData());
6464
}
6565

0 commit comments

Comments
 (0)