Skip to content

Commit a0c28bb

Browse files
Merge branch '4.0'
* 4.0: [2.7] Fix issues found by PHPStan [Command] Fix upgrade guide example Add php_unit_dedicate_assert to PHPCS [WebProfilerBundle] Let fetch() cast URL to string improve FormType::getType exception message details [Intl] Update ICU data to 60.2 [Console] fix a bug when you are passing a default value and passing -n would ouput the index [FrameworkBundle] fix merge of 3.3 into 3.4 bumped Symfony version to 4.0.3 updated VERSION for 4.0.2 updated CHANGELOG for 4.0.2 bumped Symfony version to 3.4.3 updated VERSION for 3.4.2 updated CHANGELOG for 3.4.2
2 parents e29a4f9 + f65f9a0 commit a0c28bb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

FormRegistry.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ public function getType($name)
8282

8383
if (!$type) {
8484
// Support fully-qualified class names
85-
if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) {
86-
$type = new $name();
87-
} else {
88-
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
85+
if (!class_exists($name)) {
86+
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not exist.', $name));
8987
}
88+
if (!is_subclass_of($name, 'Symfony\Component\Form\FormTypeInterface')) {
89+
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not implement "Symfony\Component\Form\FormTypeInterface".', $name));
90+
}
91+
92+
$type = new $name();
9093
}
9194

9295
$this->types[$name] = $this->resolveType($type);

0 commit comments

Comments
 (0)