8000 [Form] remove form type validation due to typehints by Tobion · Pull Request #32178 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] remove form type validation due to typehints #32178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/Symfony/Component/Form/FormConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\PropertyAccess\PropertyPath;
use Symfony\Component\PropertyAccess\PropertyPathInterface;

Expand Down Expand Up @@ -767,19 +766,12 @@ public function getFormConfig()
/**
* Validates whether the given variable is a valid form name.
*
* @param string|null $name The tested form name
*
* @throws UnexpectedTypeException if the name is not a string or an integer
* @throws InvalidArgumentException if the name contains invalid characters
*
* @internal since Symfony 4.4, to be removed in 5.0
* @internal
*/
public static function validateName($name)
final public static function validateName(?string $name)
{
if (null !== $name && !\is_string($name)) {
throw new UnexpectedTypeException($name, 'string or null');
}

if (!self::isValidName($name)) {
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));
}
Expand All @@ -794,10 +786,8 @@ public static function validateName($name)
* * starts with a letter, digit or underscore
* * contains only letters, digits, numbers, underscores ("_"),
* hyphens ("-") and colons (":")
*
* @final since Symfony 4.4
*/
public static function isValidName(?string $name): bool
final public static function isValidName(?string $name): bool
{
return '' === $name || null === $name || preg_match('/^[a-zA-Z0-9_][a-zA-Z0-9_\-:]*$/D', $name);
}
Expand Down
0