[Form] Fix php warning on invalid FormFactory::createBuilder() argument
This commit is contained in:
parent
327c647be5
commit
b5599a5897
@ -76,9 +76,11 @@ class FormFactory implements FormFactoryInterface
|
||||
} elseif ($type instanceof FormTypeInterface) {
|
||||
// BC
|
||||
$typeName = $type->getName();
|
||||
} else {
|
||||
} elseif (is_string($type)) {
|
||||
// BC
|
||||
$typeName = $type;
|
||||
} else {
|
||||
throw new UnexpectedTypeException($type, 'string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface');
|
||||
}
|
||||
|
||||
if (null === $name) {
|
||||
|
@ -293,6 +293,15 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$this->factory->createNamedBuilder('name', new \stdClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
* @expectedExceptionMessage Expected argument of type "string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface", "stdClass" given
|
||||
*/
|
||||
public function testCreateThrowsUnderstandableException()
|
||||
{
|
||||
$this->factory->create(new \stdClass());
|
||||
}
|
||||
|
||||
public function testCreateUsesTypeNameIfTypeGivenAsString()
|
||||
{
|
||||
$options = array('a' => '1', 'b' => '2');
|
||||
|
Reference in New Issue
Block a user