minor #28789 [Form] fix a return type hint (xabbuh)

This PR was merged into the 4.1 branch.

Discussion
----------

[Form] fix a return type hint

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26918
| License       | MIT
| Doc PR        |

Commits
-------

095b9f3a30 fix a return type hint
This commit is contained in:
Fabien Potencier 2018-10-10 01:47:22 -07:00
commit 5ee954c4a5
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];
$child = $this->create($name, $info['type'], $info['options']);

View File

@ -13,7 +13,9 @@ namespace Symfony\Component\Form\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ButtonBuilder;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormFactoryBuilder;
use Symfony\Component\Form\SubmitButtonBuilder;
class FormBuilderTest extends TestCase
@ -228,6 +230,14 @@ class FormBuilderTest extends TestCase
$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')
{
$mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')