fix a return type hint

This commit is contained in:
Christian Flothmann 2018-10-09 15:14:13 +02:00
parent 76a0682dca
commit 095b9f3a30
2 changed files with 12 additions and 2 deletions

View File

@ -235,9 +235,9 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
} }
/** /**
* Converts an unresolved child into a {@link FormBuilder} instance. * Converts an unresolved child into a {@link FormBuilderInterface} instance.
*/ */
private function resolveChild(string $name): self private function resolveChild(string $name): FormBuilderInterface
{ {
$info = $this->unresolvedChildren[$name]; $info = $this->unresolvedChildren[$name];
$child = $this->create($name, $info['type'], $info['options']); $child = $this->create($name, $info['type'], $info['options']);

View File

@ -13,7 +13,9 @@ namespace Symfony\Component\Form\Tests;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ButtonBuilder; use Symfony\Component\Form\ButtonBuilder;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormFactoryBuilder;
use Symfony\Component\Form\SubmitButtonBuilder; use Symfony\Component\Form\SubmitButtonBuilder;
class FormBuilderTest extends TestCase class FormBuilderTest extends TestCase
@ -228,6 +230,14 @@ class FormBuilderTest extends TestCase
$this->assertEmpty($unresolvedChildren->getValue($config)); $this->assertEmpty($unresolvedChildren->getValue($config));
} }
public function testGetButtonBuilderBeforeExplicitlyResolvingAllChildren()
{
$builder = new FormBuilder('name', null, $this->dispatcher, (new FormFactoryBuilder())->getFormFactory());
$builder->add('submit', SubmitType::class);
$this->assertInstanceOf(ButtonBuilder::class, $builder->get('submit'));
}
private function getFormBuilder($name = 'name') private function getFormBuilder($name = 'name')
{ {
$mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') $mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')