Skip to content

Commit 1b9a839

Browse files
Merge branch '2.3' into 2.7
* 2.3: Improved the PHPdoc of FileSystem::copy() [Validator] Test DNS Email constraints using checkdnsrr() mock [travis] Run real php subprocesses on hhvm for Process component tests bug #18161 [Translation] Add support for fuzzy tags in PoFileLoader [Form] Fix NumberToLocalizedStringTransformer::reverseTransform with big integers [Form] Fix INT64 cast to float in IntegerType. [SecurityBundle][PHPDoc] Added method doumentation for SecurityFactoryInterface FrameworkBundle: Client: getContainer(): fixed phpdoc [Validator] Updating inaccurate docblock comment Conflicts: .travis.yml src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
2 parents 30ddd64 + b958e68 commit 1b9a839

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,15 @@ public function reverseTransform($value)
187187
$value = str_replace(',', $decSep, $value);
188188
}
189189

190-
$result = $formatter->parse($value, \NumberFormatter::TYPE_DOUBLE, $position);
190+
if (false !== strpos($value, $decSep)) {
191+
$type = \NumberFormatter::TYPE_DOUBLE;
192+
} else {
193+
$type = PHP_INT_SIZE === 8
194+
? \NumberFormatter::TYPE_INT64
195+
: \NumberFormatter::TYPE_INT32;
196+
}
197+
198+
$result = $formatter->parse($value, $type, $position);
191199

192200
if (intl_is_failure($formatter->getErrorCode())) {
193201
throw new TransformationFailedException($formatter->getErrorMessage());

Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,11 @@ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
641641

642642
$transformer->reverseTransform("12\xc2\xa0345,678foo");
643643
}
644+
645+
public function testReverseTransformBigint()
646+
{
647+
$transformer = new NumberToLocalizedStringTransformer(null, true);
648+
649+
$this->assertEquals(PHP_INT_MAX - 1, (int) $transformer->reverseTransform((string) (PHP_INT_MAX - 1)));
650+
}
644651
}

0 commit comments

Comments
 (0)