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

Skip to content

Commit 33c6766

Browse files
committed
minor #37376 [DI][FrameworkBundle] Remove "whitelist" occurrences (chalasr)
This PR was merged into the 3.4 branch. Discussion ---------- [DI][FrameworkBundle] Remove "whitelist" occurrences | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 12ab96e [DI][FrameworkBundle] Remove whitelist occurrences
2 parents 3aa7426 + 12ab96e commit 33c6766

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class UnusedTagsPass implements CompilerPassInterface
2323
{
24-
private $whitelist = [
24+
private $knownTags = [
2525
'annotations.cached_reader',
2626
'auto_alias',
2727
'cache.pool',
@@ -70,11 +70,11 @@ class UnusedTagsPass implements CompilerPassInterface
7070

7171
public function process(ContainerBuilder $container)
7272
{
73-
$tags = array_unique(array_merge($container->findTags(), $this->whitelist));
73+
$tags = array_unique(array_merge($container->findTags(), $this->knownTags));
7474

7575
foreach ($container->findUnusedTags() as $tag) {
76-
// skip whitelisted tags
77-
if (\in_array($tag, $this->whitelist)) {
76+
// skip known tags
77+
if (\in_array($tag, $this->knownTags)) {
7878
continue;
7979
}
8080

src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-tags-whitelist.php renamed to src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515

1616
$target = dirname(__DIR__, 2).'/DependencyInjection/Compiler/UnusedTagsPass.php';
1717
$contents = file_get_contents($target);
18-
$contents = preg_replace('{private \$whitelist = \[(.+?)\];}sm', "private \$whitelist = [\n '".implode("',\n '", UnusedTagsPassUtils::getDefinedTags())."',\n ];", $contents);
18+
$contents = preg_replace('{private \$knownTags = \[(.+?)\];}sm', "private \$knownTags = [\n '".implode("',\n '", UnusedTagsPassUtils::getDefinedTags())."',\n ];", $contents);
1919
file_put_contents($target, $contents);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ public function testProcess()
3535
$this->assertSame([sprintf('%s: Tag "kenrel.event_subscriber" was defined on service(s) "foo", "bar", but was never used. Did you mean "kernel.event_subscriber"?', UnusedTagsPass::class)], $container->getCompiler()->getLog());
3636
}
3737

38-
public function testMissingWhitelistTags()
38+
public function testMissingKnownTags()
3939
{
4040
if (\dirname((new \ReflectionClass(ContainerBuilder::class))->getFileName(), 3) !== \dirname(__DIR__, 5)) {
4141
$this->markTestSkipped('Tests are not run from the root symfony/symfony metapackage.');
4242
}
4343

44-
$this->assertSame(UnusedTagsPassUtils::getDefinedTags(), $this->getWhitelistTags(), 'The src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php file must be updated; run src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-tags-whitelist.php.');
44+
$this->assertSame(UnusedTagsPassUtils::getDefinedTags(), $this->getKnownTags(), 'The src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php file must be updated; run src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php.');
4545
}
4646

47-
private function getWhitelistTags()
47+
private function getKnownTags()
4848
{
4949
// get tags in UnusedTagsPass
5050
$target = \dirname(__DIR__, 3).'/DependencyInjection/Compiler/UnusedTagsPass.php';
5151
$contents = file_get_contents($target);
52-
preg_match('{private \$whitelist = \[(.+?)\];}sm', $contents, $matches);
52+
preg_match('{private \$knownTags = \[(.+?)\];}sm', $contents, $matches);
5353
$tags = array_values(array_filter(array_map(function ($str) {
5454
return trim(preg_replace('{^ +\'(.+)\',}', '$1', $str));
5555
}, explode("\n", $matches[1]))));

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,9 +1176,9 @@ private function createService(Definition $definition, array &$inlineServices, $
11761176
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments);
11771177
// don't trigger deprecations for internal uses
11781178
// @deprecated since version 3.3, to be removed in 4.0 along with the deprecated class
1179-
$deprecationWhitelist = ['event_dispatcher' => ContainerAwareEventDispatcher::class];
1179+
$deprecationAllowlist = ['event_dispatcher' => ContainerAwareEventDispatcher::class];
11801180

1181-
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ") && (!isset($deprecationWhitelist[$id]) || $deprecationWhitelist[$id] !== $class)) {
1181+
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ") && (!isset($deprecationAllowlist[$id]) || $deprecationAllowlist[$id] !== $class)) {
11821182
@trigger_error(sprintf('The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name), E_USER_DEPRECATED);
11831183
}
11841184
}

0 commit comments

Comments
 (0)