You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Symfony version(s) affected: 4.2.0 and above (currently up until 5.1)
Description
The getTypeExtensions($name) method of \Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension throws a strange exception message:
The extended type specified for the service "0" does not match the actual extended type. Expected "Vendor\Bundle\AcmeBundle\Form\FooType", given "Vendor\Bundle\AcmeBundle\Form\BarType".
See the hightlighted code lines of the getTypeExtensions() method in the additional context below, the $serviceId variable contains the integer key of the items of the $this->typeExtensionServices[$name] iterable. Apparently, this has been set to an actual service ID by a service ID guesser before Symfony went full FQCN and now it just remains a numeric key. But the thrown exception message has not been adjusted to the new situation. This results is a very unclear error.
How to reproduce
Have a Type extension's getExtendedType(s) return invalid type(s)
Possible Solution
Clarify the exception message with useful data. Also the key in the loop is therefore probably no longer needed.
// validate the result of getExtendedTypes() to ensure it is consistent with the service definition
if (!\in_array($name, $extendedTypes, true)) {
thrownewInvalidArgumentException(sprintf('The extended type specified for the service "%s" does not match the actual extended type. Expected "%s", given "%s".', $serviceId, $name, implode(', ', $extendedTypes)));
}
}
}
The text was updated successfully, but these errors were encountered:
…'t match (xabbuh)
This PR was merged into the 4.4 branch.
Discussion
----------
[Form] provide a useful message when extension types don't match
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fix#36610
| License | MIT
| Doc PR |
Commits
-------
88d8366 provide a useful message when extension types don't match
Symfony version(s) affected: 4.2.0 and above (currently up until 5.1)
Description
The
getTypeExtensions($name)
method of \Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension throws a strange exception message:See the hightlighted code lines of the
getTypeExtensions()
method in the additional context below, the$serviceId
variable contains the integer key of the items of the$this->typeExtensionServices[$name]
iterable. Apparently, this has been set to an actual service ID by a service ID guesser before Symfony went full FQCN and now it just remains a numeric key. But the thrown exception message has not been adjusted to the new situation. This results is a very unclear error.How to reproduce
Have a Type extension's
getExtendedType
(s
) return invalid type(s)Possible Solution
Clarify the exception message with useful data. Also the key in the loop is therefore probably no longer needed.
Additional context
symfony/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php
Lines 64 to 78 in 4170346
The text was updated successfully, but these errors were encountered: