|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\MonologBundle\DependencyInjection; |
13 | 13 |
|
| 14 | +use Symfony\Component\Config\Definition\BaseNode; |
14 | 15 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
15 | 16 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
16 | 17 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
@@ -658,7 +659,7 @@ public function getConfigTreeBuilder() |
658 | 659 | ->end() |
659 | 660 | // console |
660 | 661 | ->variableNode('console_formater_options') |
661 | | - ->setDeprecated('"%path%.%node%" is deprecated, use "%path%.console_formatter_options" instead.') |
| 662 | + ->setDeprecated(...$this->getDeprecationMsg('"%path%.%node%" is deprecated, use "%path%.console_formatter_options" instead.', 3.7)) |
662 | 663 | ->validate() |
663 | 664 | ->ifTrue(function ($v) { |
664 | 665 | return !is_array($v); |
@@ -996,4 +997,27 @@ public function getConfigTreeBuilder() |
996 | 997 |
|
997 | 998 | return $treeBuilder; |
998 | 999 | } |
| 1000 | + |
| 1001 | + /** |
| 1002 | + * Returns the correct deprecation param's as an array for setDeprecated. |
| 1003 | + * |
| 1004 | + * Symfony/Config v5.1 introduces a deprecation notice when calling |
| 1005 | + * setDeprecation() with less than 3 args and the getDeprecation method was |
| 1006 | + * introduced at the same time. By checking if getDeprecation() exists, |
| 1007 | + * we can determine the correct param count to use when calling setDeprecated. |
| 1008 | + * |
| 1009 | + * @return array{0:string}|array{0:string, 1: numeric-string, string} |
| 1010 | + */ |
| 1011 | + private function getDeprecationMsg(string $message, string $version): array |
| 1012 | + { |
| 1013 | + if (method_exists(BaseNode::class, 'getDeprecation')) { |
| 1014 | + return [ |
| 1015 | + 'symfony/monolog-bundle', |
| 1016 | + $version, |
| 1017 | + $message, |
| 1018 | + ]; |
| 1019 | + } |
| 1020 | + |
| 1021 | + return [$message]; |
| 1022 | + } |
999 | 1023 | } |
0 commit comments