[Form] Tightened PropertyPath validation to reject any empty value (such as false)
This commit is contained in:
parent
7ff2a9b210
commit
2301b1559e
@ -449,13 +449,21 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException
|
||||
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testInvalidPropertyPath_null()
|
||||
{
|
||||
new PropertyPath(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testInvalidPropertyPath_false()
|
||||
{
|
||||
new PropertyPath(false);
|
||||
}
|
||||
|
||||
public function testGetParent_dot()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent.child');
|
||||
|
@ -77,8 +77,12 @@ class PropertyPath implements \IteratorAggregate
|
||||
*/
|
||||
public function __construct($propertyPath)
|
||||
{
|
||||
if ('' === $propertyPath || null === $propertyPath) {
|
||||
throw new InvalidPropertyPathException('The property path must not be empty');
|
||||
if (!is_string($propertyPath)) {
|
||||
throw new UnexpectedTypeException($propertyPath, 'string');
|
||||
}
|
||||
|
||||
if (empty($propertyPath)) {
|
||||
throw new InvalidPropertyPathException('The property path should not be empty.');
|
||||
}
|
||||
|
||||
$this->string = (string) $propertyPath;
|
||||
|
Reference in New Issue
Block a user