10000 Skip excluded tag in container by Myks92 · Pull Request #710 · rectorphp/rector-symfony · GitHub
[go: up one dir, main page]

Skip to content

Skip excluded tag in container #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector\Fixture;

use Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector\Source\ExcludedService;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();

$services->set('excluded', ExcludedService::class);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);

namespace Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector\Source;

final class ExcludedService
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<service id="second_use" class="Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector\Source\SomeServiceType"></service>

<service id="some_unique_name" class="Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector\Source\UniqueServiceType"></service>
<service id="excluded" class="Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector\Source\ExcludedService">
<tag name="container.excluded"/>
</service>
</services>
</container>
4 changes: 4 additions & 0 deletions src/ValueObjectFactory/ServiceMapFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function createFromFileContent(string $configFilePath): ServiceMap
$def = $this->convertXmlToArray($def);
$tags = $this->createTagFromXmlElement($def);

if (in_array('container.excluded', array_column($tags, 'name'), true)) {
continue;
}

$service = $this->createServiceFromXmlAndTagsData($attrs, $tags);
if ($service->getAlias() !== null) {
$aliases[] = $service;
Expand Down
Loading
0