Skip to content

Hardcode ReplaceServiceArgumentRector into ContainerInterfaceServiceToServiceContainerRector - #999

Merged
TomasVotruba merged 1 commit into
mainfrom
hardcode-container-interface-service-rule
Aug 3, 2026
Merged

Hardcode ReplaceServiceArgumentRector into ContainerInterfaceServiceToServiceContainerRector#999
TomasVotruba merged 1 commit into
mainfrom
hardcode-container-interface-service-rule

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

ReplaceServiceArgumentRector was configurable, but both sets configured it with the very same 2 values. It only ever covered a single Symfony 6.0 BC break:

Removed Psr\Container\ContainerInterface and Symfony\Component\DependencyInjection\ContainerInterface aliases of the service_container service.

So the configuration was a needless indirection. The rule is now hardcoded, renamed to ContainerInterfaceServiceToServiceContainerRector, and version-bonded to symfony/dependency-injection >=6.0 via ComposerPackageConstraintInterface.

What the rule does

 use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

-return service(ContainerInterface::class);
+return service('service_container');

Changes

  • ReplaceServiceArgumentRectorContainerInterfaceServiceToServiceContainerRector, no longer ConfigurableRectorInterface
  • ReplaceServiceArgument value object removed - no other rule uses it
  • both ContainerInterface FQNs moved to SymfonyClass enum constants
  • registered in composer-based.php in the plain rules() list under // symfony/dependency-injection 6.0, the version now comes from the rule itself
  • symfony60-dependency-injection.php uses plain rule()

…rviceToServiceContainerRector

The rule only ever handled one Symfony 6.0 BC break: the removal of the
Psr\Container\ContainerInterface and Symfony\Component\DependencyInjection\ContainerInterface
aliases of the "service_container" service. Hardcode both values, drop the
configuration and its value object, and bond the rule to
symfony/dependency-injection >=6.0 via ComposerPackageConstraintInterface.
@TomasVotruba
TomasVotruba merged commit 8d7f2db into main Aug 3, 2026
7 checks passed
@TomasVotruba
TomasVotruba deleted the hardcode-container-interface-service-rule branch August 3, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant