Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cc5cef

Browse files
feature #40468 Deprecate configuring tag names and service ids in compiler passes (nicolas-grekas)
This PR was merged into the 5.3-dev branch. Discussion ---------- Deprecate configuring tag names and service ids in compiler passes | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | - | License | MIT | Doc PR | - This PR is aimed at reducing the code complexity by hardcoding the name of tags and service ids that compiler passes have to deal with. I think making these names configurable only adds boilerplate and maintenance overhead for no benefit: - for the practice: the need to use a pass with a renamed tag/id should be extremely rare (do yo know any?) - for the theory: a decorating pass could still rename before/after the processing, so this use case is still supported. Side note: I skipped updating changelog+upgrade files. This would be just noise to me (nobody uses this possibility anyway ;) ) Commits ------- 6fe82d8 Deprecate configuring tag names and service ids in compiler passes
2 parents 5850f3d + 6fe82d8 commit 7cc5cef

File tree

42 files changed

+148
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+148
-13
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TestServiceContainerWeakRefPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class TestServiceContainerWeakRefPass implements CompilerPassInterface
2626

2727
public function __construct(string $privateTagName = 'container.private')
2828
{
29+
if (0 < \func_num_args()) {
30+
trigger_deprecation('symfony/framework-bundle', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
31+
}
32+
2933
$this->privateTagName = $privateTagName;
3034
}
3135

src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class CacheCollectorPass implements CompilerPassInterface
3232

3333
public function __construct(string $dataCollectorCacheId = 'data_collector.cache', string $cachePoolTag = 'cache.pool', string $cachePoolRecorderInnerSuffix = '.recorder_inner')
3434
{
35+
if (0 < \func_num_args()) {
36+
trigger_deprecation('symfony/cache', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
37+
}
38+
3539
$this->dataCollectorCacheId = $dataCollectorCacheId;
3640
$this->cachePoolTag = $cachePoolTag;
3741
$this->cachePoolRecorderInnerSuffix = $cachePoolRecorderInnerSuffix;

src/Symfony/Component/Cache/DependencyInjection/CachePoolClearerPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class CachePoolClearerPass implements CompilerPassInterface
2424

2525
public function __construct(string $cachePoolClearerTag = 'cache.pool.clearer')
2626
{
27+
if (0 < \func_num_args()) {
28+
trigger_deprecation('symfony/cache', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
29+
}
30+
2731
$this->cachePoolClearerTag = $cachePoolClearerTag;
2832
}
2933

src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class CachePoolPass implements CompilerPassInterface
4040

4141
public function __construct(string $cachePoolTag = 'cache.pool', string $kernelResetTag = 'kernel.reset', string $cacheClearerId = 'cache.global_clearer', string $cachePoolClearerTag = 'cache.pool.clearer', string $cacheSystemClearerId = 'cache.system_clearer', string $cacheSystemClearerTag = 'kernel.cache_clearer', string $reverseContainerId = 'reverse_container', string $reversibleTag = 'container.reversible', string $messageHandlerId = 'cache.early_expiration_handler')
4242
{
43+
if (0 < \func_num_args()) {
44+
trigger_deprecation('symfony/cache', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
45+
}
46+
4347
$this->cachePoolTag = $cachePoolTag;
4448
$this->kernelResetTag = $kernelResetTag;
4549
$this->cacheClearerId = $cacheClearerId;

src/Symfony/Component/Cache/DependencyInjection/CachePoolPrunerPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class CachePoolPrunerPass implements CompilerPassInterface
2828

2929
public function __construct(string $cacheCommandServiceId = 'console.command.cache_pool_prune', string $cachePoolTag = 'cache.pool')
3030
{
31+
if (0 < \func_num_args()) {
32+
trigger_deprecation('symfony/cache', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
33+
}
34+
3135
$this->cacheCommandServiceId = $cacheCommandServiceId;
3236
$this->cachePoolTag = $cachePoolTag;
3337
}

src/Symfony/Component/Cache/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"psr/cache": "^1.0|^2.0",
2626
"psr/log": "^1.1",
2727
"symfony/cache-contracts": "^1.1.7|^2",
28+
"symfony/deprecation-contracts": "^2.1",
2829
"symfony/polyfill-php80": "^1.15",
2930
"symfony/service-contracts": "^1.1|^2",
3031
"symfony/var-exporter": "^4.4|^5.0"

src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class AddConsoleCommandPass implements CompilerPassInterface
3636

3737
public function __construct(string $commandLoaderServiceId = 'console.command_loader', string $commandTag = 'console.command', string $noPreloadTag = 'container.no_preload', string $privateTagName = 'container.private')
3838
{
39+
if (0 < \func_num_args()) {
40+
trigger_deprecation('symfony/console', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
41+
}
42+
3943
$this->commandLoaderServiceId = $commandLoaderServiceId;
4044
$this->commandTag = $commandTag;
4145
$this->noPreloadTag = $noPreloadTag;

src/Symfony/Component/Console/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=7.2.5",
20+
"symfony/deprecation-contracts": "^2.1",
2021
"symfony/polyfill-mbstring": "~1.0",
2122
"symfony/polyfill-php73": "^1.8",
2223
"symfony/polyfill-php80": "^1.15",

src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass
2323

2424
public function __construct(string $tagName = 'container.private')
2525
{
26+
if (0 < \func_num_args()) {
27+
trigger_deprecation('symfony/dependency-injection', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
28+
}
29+
2630
$this->tagName = $tagName;
2731
}
2832

src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
*/
2020
final class AttributeAutoconfigurationPass implements CompilerPassInterface
2121
{
22-
private $ignoreAttributesTag;
23-
24-
public function __construct(string $ignoreAttributesTag = 'container.ignore_attributes')
25-
{
26-
$this->ignoreAttributesTag = $ignoreAttributesTag;
27-
}
28-
2922
public function process(ContainerBuilder $container): void
3023
{
3124
if (80000 > \PHP_VERSION_ID) {
@@ -37,7 +30,7 @@ public function process(ContainerBuilder $container): void
3730
foreach ($container->getDefinitions() as $id => $definition) {
3831
if (!$definition->isAutoconfigured()
3932
|| $definition->isAbstract()
40-
|| $definition->hasTag($this->ignoreAttributesTag)
33+
|| $definition->hasTag('container.ignore_attributes')
4134
|| !($reflector = $container->getReflectionClass($definition->getClass(), false))
4235
) {
4336
continue;

0 commit comments

Comments
 (0)