diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index e4314648df8d..7ed2f3217183 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -53,7 +53,7 @@ public function getTypeExtensions($name) $extensions = []; if (isset($this->typeExtensionServices[$name])) { - foreach ($this->typeExtensionServices[$name] as $serviceId => $extension) { + foreach ($this->typeExtensionServices[$name] as $extension) { $extensions[] = $extension; if (method_exists($extension, 'getExtendedTypes')) { @@ -68,7 +68,7 @@ public function getTypeExtensions($name) // validate the result of getExtendedTypes()/getExtendedType() to ensure it is consistent with the service definition if (!\in_array($name, $extendedTypes, true)) { - throw new InvalidArgumentException(sprintf('The extended type specified for the service "%s" does not match the actual extended type. Expected "%s", given "%s".', $serviceId, $name, implode(', ', $extendedTypes))); + throw new InvalidArgumentException(sprintf('The extended type "%s" specified for the type extension class "%s" does not match any of the actual extended types (["%s"]).', $name, \get_class($extension), implode('", "', $extendedTypes))); } } } diff --git a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php index 923ad8a38f61..26db2d8cea28 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php @@ -44,6 +44,8 @@ public function testGetTypeExtensions() public function testThrowExceptionForInvalidExtendedType() { $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectExceptionMessage(sprintf('The extended type "unmatched" specified for the type extension class "%s" does not match any of the actual extended types (["test"]).', TestTypeExtension::class)); + $extensions = [ 'unmatched' => new \ArrayIterator([new TestTypeExtension()]), ];