[Form] Fix INT64 cast to float in IntegerType.
This commit is contained in:
parent
5d8067f32d
commit
6b6073f685
@ -122,7 +122,11 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
|
||||
$value = str_replace(',', $decSep, $value);
|
||||
}
|
||||
|
||||
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());
|
||||
|
@ -433,4 +433,11 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$transformer->reverseTransform("12\xc2\xa0345,678foo");
|
||||
}
|
||||
|
||||
public function testReverseTransformBigint()
|
||||
{
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
$this->assertEquals(401657096594165125, (int) $transformer->reverseTransform((string) 401657096594165125));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user