From 9ed4d1ab033290b30d7bb8eced98526d96582461 Mon Sep 17 00:00:00 2001 From: Jesse Rushlow <40327885+jrushlow@users.noreply.github.com> Date: Fri, 3 Apr 2020 11:13:51 -0400 Subject: [PATCH] Fix deprecation around deprecating config nodes (#1153) --- DependencyInjection/Configuration.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e6e3fd1cb..8c342cc0b 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -4,6 +4,7 @@ use Doctrine\ORM\EntityManager; use ReflectionClass; +use Symfony\Component\Config\Definition\BaseNode; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; @@ -91,7 +92,7 @@ private function addDbalSection(ArrayNodeDefinition $node) : void ->end() ->children() ->scalarNode('class')->isRequired()->end() - ->booleanNode('commented')->setDeprecated()->end() + ->booleanNode('commented')->setDeprecated(...$this->getCommentedParamDeprecationMsg())->end() ->end() ->end() ->end() @@ -685,4 +686,27 @@ private function getAutoGenerateModes() : array 'values' => $valuesArray, ]; } + + /** + * Returns the correct deprecation param's as an array for setDeprecated. + * + * Symfony/Config v5.1 introduces a deprecation notice when calling + * setDeprecation() with less than 3 args and the getDeprecation method was + * introduced at the same time. By checking if getDeprecation() exists, + * we can determine the correct param count to use when calling setDeprecated. + */ + private function getCommentedParamDeprecationMsg() : array + { + $message = 'The doctrine-bundle type commenting features were removed; the corresponding config parameter was deprecated in 2.0 and will be dropped in 3.0.'; + + if (method_exists(BaseNode::class, 'getDeprecation')) { + return [ + 'doctrine/doctrine-bundle', + '2.0', + $message, + ]; + } + + return [$message]; + } }