8000 Removed legacy code from NumberType · symfony/symfony@148ba1f · GitHub
[go: up one dir, main page]

Skip to content

Commit 148ba1f

Browse files
committed
Removed legacy code from NumberType
1 parent 0c90809 commit 148ba1f

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CHANGELOG
1717
* removed the `$scale` argument of the `IntegerToLocalizedStringTransformer`
1818
* removed `TemplatingExtension` and `TemplatingRendererEngine` classes, use Twig instead
1919
* passing a null message when instantiating a `Symfony\Component\Form\FormError` is not allowed
20+
* removed support for using `int` or `float` as data for the `NumberType` when the `input` option is set to `string`
2021

2122
4.4.0
2223
-----

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15-
use Symfony\Component\Form\CallbackTransformer;
1615
use Symfony\Component\Form\Exception\LogicException;
1716
use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
1817
use Symfony\Component\Form\Extension\Core\DataTransformer\StringToFloatTransformer;
@@ -38,19 +37,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
3837

3938
if ('string' === $options['input']) {
4039
$builder->addModelTransformer(new StringToFloatTransformer($options['scale']));
41-
$builder->addModelTransformer(new CallbackTransformer(
42-
function ($value) {
43-
if (\is_float($value) || \is_int($value)) {
44-
@trigger_error(sprintf('Using the %s with float or int data when the "input" option is set to "string" is deprecated since Symfony 4.4 and will throw an exception in 5.0.', self::class), E_USER_DEPRECATED);
45-
$value = (string) $value;
46-
}
47-
48-
return $value;
49-
},
50-
function ($value) {
51-
return $value;
52-
}
53-
));
5440
}
5541
}
5642

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,27 @@ public function testDefaultFormattingWithScaleAndStringInput(): void
7878
}
7979

8080
/**
81-
* @group legacy
82-
* @expectedDeprecation Using the Symfony\Component\Form\Extension\Core\Type\NumberType with float or int data when the "input" option is set to "string" is deprecated since Symfony 4.4 and will throw an exception in 5.0.
81+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
82+
* @expectedExceptionMessage Expected a numeric string.
8383
*/
8484
public function testStringInputWithFloatData(): void
8585
{
86-
$form = $this->factory->create(static::TESTED_TYPE, 12345.6789, [
86+
$this->factory->create(static::TESTED_TYPE, 12345.6789, [
8787
'input' => 'string',
8888
'scale' => 2,
8989
]);
90-
91-
$this->assertSame('12345,68', $form->createView()->vars['value']);
9290
}
9391

9492
/**
95-
* @group legacy
96-
* @expectedDeprecation Using the Symfony\Component\Form\Extension\Core\Type\NumberType with float or int data when the "input" option is set to "string" is deprecated since Symfony 4.4 and will throw an exception in 5.0.
93+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
94+
* @expectedExceptionMessage Expected a numeric string.
9795
*/
9896
public function testStringInputWithIntData(): void
9997
{
100-
$form = $this->factory->create(static::TESTED_TYPE, 12345, [
98+
$this->factory->create(static::TESTED_TYPE, 12345, [
10199
'input' => 'string',
102100
'scale' => 2,
103101
]);
104-
105-
$this->assertSame('12345,00', $form->createView()->vars['value']);
106102
}
107103

108104
public function testDefaultFormattingWithRounding(): void

0 commit comments

Comments
 (0)
0