Skip to content

Commit 9508e43

Browse files
Merge branch '2.8' into 3.3
* 2.8: [2.7] Fix issues found by PHPStan Add php_unit_dedicate_assert to PHPCS 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
2 parents 3fb8d2d + 97a7dbf commit 9508e43

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
@@ -79,11 +79,14 @@ public function getType($name)
7979

8080
if (!$type) {
8181
// Support fully-qualified class names
82-
if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) {
83-
$type = new $name();
84-
} else {
85-
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
82+
if (!class_exists($name)) {
83+
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not exist.', $name));
8684
}
85+
if (!is_subclass_of($name, 'Symfony\Component\Form\FormTypeInterface')) {
86+
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not implement "Symfony\Component\Form\FormTypeInterface".', $name));
87+
}
88+
89+
$type = new $name();
8790
}
8891

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

0 commit comments

Comments
 (0)