10000 minor #32934 [Form] type cannot be a FormTypeInterface anymore (Tobion) · symfony/symfony@c754f15 · GitHub
[go: up one dir, main page]

Skip to content

Commit c754f15

Browse files
committed
minor #32934 [Form] type cannot be a FormTypeInterface anymore (Tobion)
This PR was merged into the 4.4 branch. Discussion ---------- [Form] type cannot be a FormTypeInterface anymore | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | | License | MIT | Doc PR | Found in #32237. This style of adding FormTypes has been removed in sf 3. Could also be merged in 3.4 if preferred. But there was an outdated, broken test. So 4.4 seems enough as well. Commits ------- 6ee0d53 [Form] type cannot be a FormTypeInterface anymore
2 parents 748dd8e + 6ee0d53 commit c754f15

File tree

4 files changed

+4
-18
lines changed

4 files changed

+4
-18
lines changed

src/Symfony/Component/Form/ButtonBuilder.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ public function __construct(?string $name, array $options = [])
7979
*
8080
* This method should not be invoked.
8181
*
82-
* @param string|FormBuilderInterface $child
83-
* @param string|FormTypeInterface $type
84-
*
8582
* @throws BadMethodCallException
8683
*/
8784
public function add($child, $type = null, array $options = [])
@@ -94,10 +91,6 @@ public function add($child, $type = null, array $options = [])
9491
*
9592
* This method should not be invoked.
9693
*
97-
* @param string $name
98-
* @param string|FormTypeInterface $type
99-
* @param array $options
100-
*
10194
* @throws BadMethodCallException
10295
*/
10396
public function create($name, $type = null, array $options = [])

src/Symfony/Component/Form/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,8 @@ public function add($child, $type = null, array $options = [])
849849

850850
$child = (string) $child;
851851

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

856856
// Never initialize child forms automatically

src/Symfony/Component/Form/FormBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function add($child, $type = null, array $options = [])
6666
throw new UnexpectedTypeException($child, 'string or Symfony\Component\Form\FormBuilderInterface');
6767
}
6868

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

7373
// Add to "children" to maintain order

src/Symfony/Component/Form/Tests/FormBuilderTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,6 @@ public function testMaintainOrderOfLazyAndExplicitChildren()
120120
$this->assertSame(['foo', 'bar', 'baz'], array_keys($children));
121121
}
122122

123-
public function testAddFormType()
124-
{
125-
$this->assertFalse($this->builder->has('foo'));
126-
$this->builder->add('foo', $this->getMockBuilder('Symfony\Component\Form\FormTypeInterface')->getMock());
127-
$this->assertTrue($this->builder->has('foo'));
128-
}
129-
130123
public function testRemove()
131124
{
132125
$this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType');

0 commit comments

Comments
 (0)
0