diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md new file mode 100644 index 000000000000..ec1852e3e468 --- /dev/null +++ b/UPGRADE-4.4.md @@ -0,0 +1,21 @@ +UPGRADE FROM 4.3 to 4.4 +======================= + +DependencyInjection +------------------- + + * Deprecated support for short factories and short configurators in Yaml + + Before: + ```yaml + services: + my_service: + factory: factory_service:method + ``` + + After: + ```yaml + services: + my_service: + factory: ['@factory_service', method] + ``` diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 6f71eb546c8a..74c8bd458060 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -69,6 +69,22 @@ DependencyInjection env(NAME): '1.5' ``` + * Removed support for short factories and short configurators in Yaml + + Before: + ```yaml + services: + my_service: + factory: factory_service:method + ``` + + After: + ```yaml + services: + my_service: + factory: ['@factory_service', method] + ``` + DoctrineBridge -------------- diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index bc54b5f38c36..152a17ce9a46 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.4.0 +----- + + * deprecated support for short factories and short configurators in Yaml + 4.3.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 703620c8a67e..cbb39ae0357d 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -574,28 +574,29 @@ private function parseDefinition($id, $service, $file, array $defaults) /** * Parses a callable. * - * @param string|array $callable A callable - * @param string $parameter A parameter (e.g. 'factory' or 'configurator') - * @param string $id A service identifier - * @param string $file A parsed file + * @param string|array $callable A callable reference + * @param string $parameter The type of callable (e.g. 'factory' or 'configurator') * * @throws InvalidArgumentException When errors occur * * @return string|array|Reference A parsed callable */ - private function parseCallable($callable, $parameter, $id, $file) + private function parseCallable($callable, string $parameter, string $id, string $file) { if (\is_string($callable)) { if ('' !== $callable && '@' === $callable[0]) { if (false === strpos($callable, ':')) { return [$this->resolveServices($callable, $file), '__invoke']; } - throw new InvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $parameter, $id, $callable, substr($callable, 1))); + + throw new InvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s" in "%s").', $parameter, $id, $callable, substr($callable, 1), $file)); } if (false !== strpos($callable, ':') && false === strpos($callable, '::')) { $parts = explode(':', $callable); + @trigger_error(sprintf('Using short %s syntax for service "%s" is deprecated since Symfony 4.4, use "[\'@%s\', \'%s\']" instead.', $parameter, $id, ...$parts), E_USER_DEPRECATED); + return [$this->resolveServices('@'.$parts[0], $file), $parts[1]]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 609a54d0fdef..0aa30f288c70 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -191,6 +191,9 @@ public function testDeprecatedAliases() $this->assertSame($message, $container->getAlias('alias_for_foobar')->getDeprecationMessage('alias_for_foobar')); } + /** + * @group legacy + */ public function testLoadFactoryShortSyntax() { $container = new ContainerBuilder(); @@ -208,10 +211,13 @@ public function testFactorySyntaxError() $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('The value of the "factory" option for the "invalid_factory" service must be the id of the service without the "@" prefix (replace "@factory:method" with "factory:method").'); + $this->expectExceptionMessage('The value of the "factory" option for the "invalid_factory" service must be the id of the service without the "@" prefix (replace "@factory:method" with "factory:method"'); $loader->load('bad_factory_syntax.yml'); } + /** + * @group legacy + */ public function testLoadConfiguratorShortSyntax() { $container = new ContainerBuilder(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy