Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a check to see if the type is a string if it's not a FormTypeIn…

…terface
  • Loading branch information...
commit d97d7e93c0a8192a39e1dda65ddba0564f807e14 1 parent e3421a0
@Burgov Burgov authored
View
4 src/Symfony/Component/Form/FormFactory.php
@@ -225,8 +225,10 @@ public function createNamedBuilder($type, $name, $data = null, array $options =
}
$this->addType($type);
- } else {
+ } elseif (is_string($type)) {
$type = $this->getType($type);
+ } else {
+ throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface');
}
$defaultOptions = $type->getDefaultOptions($options);
View
9 tests/Symfony/Tests/Component/Form/FormFactoryTest.php
@@ -320,6 +320,15 @@ public function testCreateNamedBuilderAddsTypeInstances()
$this->assertTrue($this->factory->hasType('foo'));
}
+ /**
+ * @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
+ * @expectedExceptionMessage Expected argument of type "string or Symfony\Component\Form\FormTypeInterface", "stdClass" given
+ */
+ public function testCreateNamedBuilderThrowsUnderstandableException()
+ {
+ $this->factory->createNamedBuilder(new \StdClass, 'name');
+ }
+
public function testCreateUsesTypeNameAsName()
{
$type = new FooType();
Please sign in to comment.
Something went wrong with that request. Please try again.