Skip to content

Commit

Permalink
minor #16309 [Form] remove type check in FormRegistry::getType (Tobion)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Oct 25, 2015
2 parents ef242af + d37b9e6 commit 2d58871
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 25 deletions.
4 changes: 0 additions & 4 deletions src/Symfony/Component/Form/FormRegistry.php
Expand Up @@ -69,10 +69,6 @@ public function __construct(array $extensions, ResolvedFormTypeFactoryInterface
*/
public function getType($name)
{
if (!is_string($name)) {
throw new UnexpectedTypeException($name, 'string');
}

if (!isset($this->types[$name])) {
$type = null;

Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Form/FormRegistryInterface.php
Expand Up @@ -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);
Expand Down
20 changes: 0 additions & 20 deletions src/Symfony/Component/Form/Tests/FormRegistryTest.php
Expand Up @@ -172,18 +172,6 @@ public function testGetTypeConnectsParentIfGetParentReturnsInstance()
$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
*/
Expand All @@ -192,14 +180,6 @@ public function testGetTypeThrowsExceptionIfTypeNotFound()
$this->registry->getType('bar');
}

/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testGetTypeThrowsExceptionIfNoString()
{
$this->registry->getType(array());
}

public function testHasTypeAfterLoadingFromExtension()
{
$type = new FooType();
Expand Down

0 comments on commit 2d58871

Please sign in to comment.