minor #16309 [Form] remove type check in FormRegistry::getType (Tobion)

This PR was merged into the 2.3 branch.

Discussion
----------

[Form] remove type check in FormRegistry::getType

| Q             | A
| ------------- | ---
| Bug fix?      | yes (consistency)
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

remove validation of `FormRegistry::getType` as `FormRegistry::hasType` does not validate either. So `hasType` currently triggers a PHP warning with a wrong argument.
also developers do not work with the registry directly anyway but through the factory. and the factory already validates the value. So this validation is useless in reality.

Commits
-------

d37b9e6 [Form] remove validation of FormRegistry::getType as FormRegistry::hasType does not validate either
This commit is contained in:
Fabien Potencier 2015-10-25 17:34:32 +01:00
commit 2d588710ff
3 changed files with 0 additions and 25 deletions

View File

@ -69,10 +69,6 @@ class FormRegistry implements FormRegistryInterface
*/
public function getType($name)
{
if (!is_string($name)) {
throw new UnexpectedTypeException($name, 'string');
}
if (!isset($this->types[$name])) {
$type = null;

View File

@ -27,7 +27,6 @@ interface FormRegistryInterface
*
* @return ResolvedFormTypeInterface The type
*
* @throws Exception\UnexpectedTypeException if the passed name is not a string
* @throws Exception\InvalidArgumentException if the type can not be retrieved from any extension
*/
public function getType($name);

View File

@ -172,18 +172,6 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
$this->assertSame($resolvedType, $this->registry->getType('foo_sub_type_parent_instance'));
}
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testGetTypeThrowsExceptionIfParentNotFound()
{
$type = new FooSubType();
$this->extension1->addType($type);
$this->registry->getType($type);
}
/**
* @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
*/
@ -192,14 +180,6 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
$this->registry->getType('bar');
}
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testGetTypeThrowsExceptionIfNoString()
{
$this->registry->getType(array());
}
public function testHasTypeAfterLoadingFromExtension()
{
$type = new FooType();