Skip to content

Commit ba2b5c1

Browse files
committed
[Form] remove form type validation due to typehints
1 parent 06899a1 commit ba2b5c1

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/Symfony/Component/Form/FormConfigBuilder.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
1717
use Symfony\Component\Form\Exception\BadMethodCallException;
1818
use Symfony\Component\Form\Exception\InvalidArgumentException;
19-
use Symfony\Component\Form\Exception\UnexpectedTypeException;
2019
use Symfony\Component\PropertyAccess\PropertyPath;
2120
use Symfony\Component\PropertyAccess\PropertyPathInterface;
2221

@@ -767,19 +766,12 @@ public function getFormConfig()
767766
/**
768767
* Validates whether the given variable is a valid form name.
769768
*
770-
* @param string|null $name The tested form name
771-
*
772-
* @throws UnexpectedTypeException if the name is not a string or an integer
773769
* @throws InvalidArgumentException if the name contains invalid characters
774770
*
775-
* @internal since Symfony 4.4, to be removed in 5.0
771+
* @internal
776772
*/
777-
public static function validateName($name)
773+
final public static function validateName(?string $name)
778774
{
779-
if (null !== $name && !\is_string($name)) {
780-
throw new UnexpectedTypeException($name, 'string or null');
781-
}
782-
783775
if (!self::isValidName($name)) {
784776
throw new InvalidArgumentException(sprintf('The name "%s" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").', $name));
785777
}
@@ -794,10 +786,8 @@ public static function validateName($name)
794786
* * starts with a letter, digit or underscore
795787
* * contains only letters, digits, numbers, underscores ("_"),
796788
* hyphens ("-") and colons (":")
797-
*
798-
* @final since Symfony 4.4
799789
*/
800-
public static function isValidName(?string $name): bool
790+
final public static function isValidName(?string $name): bool
801791
{
802792
return '' === $name || null === $name || preg_match('/^[a-zA-Z0-9_][a-zA-Z0-9_\-:]*$/D', $name);
803793
}

0 commit comments

Comments
 (0)