Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc4ee93d

Browse files
committed
Configure NumberFormatter::ROUND_HALFUP as default rounding_mode
1 parentda0f36f commitc4ee93d

File tree

4 files changed

+2
-50
lines changed

4 files changed

+2
-50
lines changed

‎src/Symfony/Component/Form/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
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‎

Lines changed: 1 addition & 12 deletions
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-
returnnull;
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‎

Lines changed: 0 additions & 5 deletions
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‎

Lines changed: 0 additions & 33 deletions
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-
publicfunctiontestSubmitWithoutRoundingMode()
90-
{
91-
$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.');
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-
publicfunctiontestSubmitWithNullRoundingMode()
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)

[8]ページ先頭

©2009-2025 Movatter.jp