Skip to content

[Form] type cannot be a FormTypeInterface anymore #32934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/Symfony/Component/Form/ButtonBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public function __construct(?string $name, array $options = [])
*
* This method should not be invoked.
*
* @param string|FormBuilderInterface $child
* @param string|FormTypeInterface $type
*
* @throws BadMethodCallException
*/
public function add($child, $type = null, array $options = [])
Expand All @@ -94,10 +91,6 @@ public function add($child, $type = null, array $options = [])
*
* This method should not be invoked.
*
* @param string $name
* @param string|FormTypeInterface $type
* @param array $options
*
* @throws BadMethodCallException
*/
public function create($name, $type = null, array $options = [])
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,8 @@ public function add($child, $type = null, array $options = [])

$child = (string) $child;

if (null !== $type && !\is_string($type) && !$type instanceof FormTypeInterface) {
throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface');
if (null !== $type && !\is_string($type)) {
throw new UnexpectedTypeException($type, 'string or null');
}

// Never initialize child forms automatically
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function add($child, $type = null, array $options = [])
throw new UnexpectedTypeException($child, 'string or Symfony\Component\Form\FormBuilderInterface');
}

if (null !== $type && !\is_string($type) && !$type instanceof FormTypeInterface) {
throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface');
if (null !== $type && !\is_string($type)) {
throw new UnexpectedTypeException($type, 'string or null');
}

// Add to "children" to maintain order
Expand Down
7 changes: 0 additions & 7 deletions src/Symfony/Component/Form/Tests/FormBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ public function testMaintainOrderOfLazyAndExplicitChildren()
$this->assertSame(['foo', 'bar', 'baz'], array_keys($children));
}

public function testAddFormType()
{
$this->assertFalse($this->builder->has('foo'));
$this->builder->add('foo', $this->getMockBuilder('Symfony\Component\Form\FormTypeInterface')->getMock());
$this->assertTrue($this->builder->has('foo'));
}

public function testRemove()
{
$this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType');
Expand Down