8000 [Form] Remove the scale argument of the IntegerToLocalizedStringTransformer by yceruto · Pull Request #31706 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Remove the scale argument of the IntegerToLocalizedStringTransformer #31706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/Form/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CHANGELOG
* added static `getExtendedTypes()` method to the `FormTypeExtensionInterface`
* calling to `FormRenderer::searchAndRenderBlock()` method for fields which were already rendered throw a `BadMethodCallException`
* removed the `regions` option of the `TimezoneType`
* removed the `$scale` argument of the `IntegerToLocalizedStringTransformer`

4.3.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo
* @param bool $grouping Whether thousands should be grouped
* @param int $roundingMode One of the ROUND_ constants in this class
*/
public function __construct($grouping = false, $roundingMode = self::ROUND_DOWN)
public function __construct(?bool $grouping = false, ?int $roundingMode = self::ROUND_DOWN)
{
if (\is_int($grouping) || \is_bool($roundingMode) || 2 < \func_num_args()) {
@trigger_error(sprintf('Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0.', __CLASS__), E_USER_DEPRECATED);

$grouping = $roundingMode;
$roundingMode = 2 < \func_num_args() ? func_get_arg(2) : self::ROUND_DOWN;
}

parent::__construct(0, $grouping, $roundingMode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,6 @@ public function testTransformWithRounding($input, $output, $roundingMode)
$this->assertEquals($output, $transformer->transform($input));
}

/**
* @group legacy
* @expectedDeprecation Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0.
* @dataProvider transformWithRoundingProvider
*/
public function testTransformWithRoundingUsingLegacyConstructorSignature($input, $output, $roundingMode)
{
$transformer = new IntegerToLocalizedStringTransformer(null, null, $roundingMode);

$this->assertEquals($output, $transformer->transform($input));
}

public function testReverseTransform()
{
// Since we test against "de_AT", we need the full implementation
Expand Down Expand Up @@ -138,25 +126,6 @@ public function testReverseTransformWithGrouping()
$this->assertEquals(12345, $transformer->reverseTransform('12345'));
}

/**
* @group legacy
* @expectedDeprecation Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0.
*/
public function testReverseTransformWithGroupingUsingLegacyConstructorSignature()
{
// Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this, false);

\Locale::setDefault('de_DE');

$transformer = new IntegerToLocalizedStringTransformer(null, true);

$this->assertEquals(1234, $transformer->reverseTransform('1.234'));
$this->assertEquals(12345, $transformer->reverseTransform('12.345'));
$this->assertEquals(1234, $transformer->reverseTransform('1234'));
$this->assertEquals(12345, $transformer->reverseTransform('12345'));
}

public function reverseTransformWithRoundingProvider()
{
return [
Expand Down Expand Up @@ -218,18 +187,6 @@ public function testReverseTransformWithRounding($input, $output, $roundingMode)
$this->assertEquals($output, $transformer->reverseTransform($input));
}

/**
* @group legacy
* @expectedDeprecation Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0.
* @dataProvider reverseTransformWithRoundingProvider
*/
public function testReverseTransformWithRoundingUsingLegacyConstructorSignature($input, $output, $roundingMode)
{
$transformer = new IntegerToLocalizedStringTransformer(null, null, $roundingMode);

$this->assertEquals($output, $transformer->reverseTransform($input));
}

/**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/
Expand Down
0