8000 [Form] Fix NumberToLocalizedStringTransformer::reverseTransform with big integers by nicolas-grekas · Pull Request #18179 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Fix NumberToLocalizedStringTransformer::reverseTransform with big integers #18179

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 2 commits into from
Mar 15, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Diff view
Next Next commit
[Form] Fix INT64 cast to float in IntegerType.
  • Loading branch information
ovrflo authored and nicolas-grekas committed Mar 15, 2016
commit 6b6073f68585415c050c8b6bf0b17efa10cd6cb7
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ public function reverseTransform($value)
$value = str_replace(',', $decSep, $value);
}

$result = $formatter->parse($value, \NumberFormatter::TYPE_DOUBLE, $position);
if (!strstr($value, $decSep) && PHP_INT_SIZE === 8) {
$result = $formatter->parse($value, \NumberFormatter::TYPE_INT64, $position);
} else {
$result = $formatter->parse($value, \NumberFormatter::TYPE_DOUBLE, $position);
}

if (intl_is_failure($formatter->getErrorCode())) {
throw new TransformationFailedException($formatter->getErrorMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,11 @@ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()

$transformer->reverseTransform("12\xc2\xa0345,678foo");
}

public function testReverseTransformBigint()
{
$transformer = new NumberToLocalizedStringTransformer(null, true);

$this->assertEquals(401657096594165125, (int) $transformer->reverseTransform((string) 401657096594165125));
}
}
0