Merge branch '3.4' into 4.1
* 3.4: typo add a test case [Form] Handle all case variants of "nan" when parsing a number
This commit is contained in:
commit
a4bc4ac0ce
@ -146,7 +146,7 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('NaN' === $value) {
|
if (\in_array($value, array('NaN', 'NAN', 'nan'), true)) {
|
||||||
throw new TransformationFailedException('"NaN" is not a valid number');
|
throw new TransformationFailedException('"NaN" is not a valid number');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,24 +514,24 @@ class NumberToLocalizedStringTransformerTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||||
|
* @dataProvider nanRepresentationProvider
|
||||||
*
|
*
|
||||||
* @see https://github.com/symfony/symfony/issues/3161
|
* @see https://github.com/symfony/symfony/issues/3161
|
||||||
*/
|
*/
|
||||||
public function testReverseTransformDisallowsNaN()
|
public function testReverseTransformDisallowsNaN($nan)
|
||||||
{
|
{
|
||||||
$transformer = new NumberToLocalizedStringTransformer();
|
$transformer = new NumberToLocalizedStringTransformer();
|
||||||
|
|
||||||
$transformer->reverseTransform('NaN');
|
$transformer->reverseTransform($nan);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function nanRepresentationProvider()
|
||||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
|
||||||
*/
|
|
||||||
public function testReverseTransformDisallowsNaN2()
|
|
||||||
{
|
{
|
||||||
$transformer = new NumberToLocalizedStringTransformer();
|
return array(
|
||||||
|
array('nan'),
|
||||||
$transformer->reverseTransform('nan');
|
array('NaN'), // see https://github.com/symfony/symfony/issues/3161
|
||||||
|
array('NAN'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +112,7 @@ interface ExecutionContextInterface
|
|||||||
* Returns the currently validated object.
|
* Returns the currently validated object.
|
||||||
*
|
*
|
||||||
* If the validator is currently validating a class constraint, the
|
* If the validator is currently validating a class constraint, the
|
||||||
* object of that class is returned. If it is a validating a property or
|
* object of that class is returned. If it is validating a property or
|
||||||
* getter constraint, the object that the property/getter belongs to is
|
* getter constraint, the object that the property/getter belongs to is
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user