Skip to content

Commit

Permalink
Fix deprecation around deprecating config nodes (#1153)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow committed Apr 3, 2020
1 parent 26c16fa commit bda5f51
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion DependencyInjection/Configuration.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -689,4 +690,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];
}
}

0 comments on commit bda5f51

Please sign in to comment.