8000 Configure NumberFormatter::ROUND_HALFUP as default rounding_mode · symfony/symfony@c4ee93d · GitHub
[go: up one dir, main page]

Skip to content

Commit c4ee93d

Browse files
committed
Configure NumberFormatter::ROUND_HALFUP as default rounding_mode
1 parent da0f36f commit c4ee93d

File tree

4 files changed

+2
-50
lines changed

4 files changed

+2
-50
lines changed

src/Symfony/Component/Form/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Remove `Symfony\Component\Form\Extension\Validator\Util\ServiceParams`
99
* Remove `FormPass` configuration
1010
* Add `FormConfigInterface::getIsEmptyCallback()` and `FormConfigBuilderInterface::setIsEmptyCallback()`
11+
* Configure `NumberFormatter::ROUND_HALFUP` as default value of `rounding_mode` option of the `PercentType`
1112

1213
5.3
1314
---

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

+1-12
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ public function configureOptions(OptionsResolver $resolver)
5353
{
5454
$resolver->setDefaults([
5555
'scale' => 0,
56-
'rounding_mode' => function (Options $options) {
57-
trigger_deprecation('symfony/form', '5.1', 'Not configuring the "rounding_mode" option is deprecated. It will default to "\NumberFormatter::ROUND_HALFUP" in Symfony 6.0.');
58-
59-
return null;
60-
},
56+
'rounding_mode' => \NumberFormatter::ROUND_HALFUP,
6157
'symbol' => '%',
6258
'type' => 'fractional',
6359
'compound' => false,
@@ -85,13 +81,6 @@ public function configureOptions(OptionsResolver $resolver)
8581
]);
8682
$resolver->setAllowedTypes('scale', 'int');
8783
$resolver->setAllowedTypes('symbol', ['bool', 'string']);
88-
$resolver->setDeprecated('rounding_mode', 'symfony/form', '5.1', function (Options $options, $roundingMode) {
89-
if (null === $roundingMode) {
90-
return 'Not configuring the "rounding_mode" option is deprecated. It will default to "\NumberFormatter::ROUND_HALFUP" in Symfony 6.0.';
91-
}
92-
93-
return '';
94-
});
9584
$resolver->setAllowedTypes('html5', 'bool');
9685
}
9786

src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ public function testDebugDeprecatedDefaults()
4242
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
4343
$this->assertSame(<<<TXT
4444
45-
Built-in form types (Symfony\Component\Form\Extension\Core\Type)
46-
----------------------------------------------------------------
47-
48-
PercentType
49-
5045
Service form types
5146
------------------
5247

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

-33
Original file line numberDiff line numberDiff line change
@@ -82,37 +82,4 @@ public function testHtml5EnablesSpecificFormatting()
8282
$this->assertSame('1234.56', $form->createView()->vars['value']);
8383
$this->assertSame('number', $form->createView()->vars['type']);
8484
}
85-
86-
/**
87-
* @group legacy
88-
*/
89-
public function testSubmitWithoutRoundingMode()
90-
{
91-
$this->expectDepre E864 cation('Since symfony/form 5.1: Not configuring the "rounding_mode" option is deprecated. It will default to "\NumberFormatter::ROUND_HALFUP" in Symfony 6.0.');
92-
93-
$form = $this->factory->create(self::TESTED_TYPE, null, [
94-
'scale' => 2,
95-
]);
96-
97-
$form->submit('1.23456');
98-
99-
$this->assertEquals(0.0123456, $form->getData());
100-
}
101-
102-
/**
103-
* @group legacy
104-
*/
105-
public function testSubmitWithNullRoundingMode()
106-
{
107-
$this->expectDeprecation('Since symfony/form 5.1: Not configuring the "rounding_mode" option is deprecated. It will default to "\NumberFormatter::ROUND_HALFUP" in Symfony 6.0.');
108-
109-
$form = $this->factory->create(self::TESTED_TYPE, null, [
110-
'rounding_mode' => null,
111-
'scale' => 2,
112-
]);
113-
114-
$form->submit('1.23456');
115-
116-
$this->assertEquals(0.0123456, $form->getData());
117-
}
11885
}

0 commit comments

Comments
 (0)
0