From d37b9e699df01fdff46646fedb18f1231aa019c5 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 22 Oct 2015 02:46:43 +0200 Subject: [PATCH] [Form] remove validation of FormRegistry::getType as FormRegistry::hasType does not validate either also developers do not work with the registry directly anyway but through the factory. and the factory already validates the value. --- src/Symfony/Component/Form/FormRegistry.php | 4 ---- .../Component/Form/FormRegistryInterface.php | 1 - .../Component/Form/Tests/FormRegistryTest.php | 20 ------------------- 3 files changed, 25 deletions(-) diff --git a/src/Symfony/Component/Form/FormRegistry.php b/src/Symfony/Component/Form/FormRegistry.php index 0dc21df2bc..67cfca06aa 100644 --- a/src/Symfony/Component/Form/FormRegistry.php +++ b/src/Symfony/Component/Form/FormRegistry.php @@ -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; diff --git a/src/Symfony/Component/Form/FormRegistryInterface.php b/src/Symfony/Component/Form/FormRegistryInterface.php index b42b2b5818..f16c0cb8fb 100644 --- a/src/Symfony/Component/Form/FormRegistryInterface.php +++ b/src/Symfony/Component/Form/FormRegistryInterface.php @@ -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); diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index 0c8bb6b441..c99e45edf0 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -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();