Skip to content

fix: use ResetInterface to support Symfony 8.1#317

Merged
DavidBadura merged 1 commit into
patchlevel:3.17.xfrom
kochen:fix/symfony-8-1-reset-services-listener
Jun 2, 2026
Merged

fix: use ResetInterface to support Symfony 8.1#317
DavidBadura merged 1 commit into
patchlevel:3.17.xfrom
kochen:fix/symfony-8-1-reset-services-listener

Conversation

@kochen
Copy link
Copy Markdown
Contributor

@kochen kochen commented Jun 1, 2026

Problem

Symfony 8.1 moved ServicesResetter from HttpKernel\DependencyInjection to DependencyInjection (symfony/symfony commit). The container now injects Symfony\Component\DependencyInjection\ServicesResetter. Since HttpKernel\ServicesResetter extends the DI version (not the other way around), passing the DI version where the HttpKernel subclass is expected causes a TypeError at container boot.

Fix

Change the type hint from Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter to Symfony\Contracts\Service\ResetInterface:

  • Works across Symfony 6.4, 7.x, and 8.x
  • ServicesResetter has always implemented ResetInterface
  • Same approach used by Symfony's own Messenger\EventListener\ResetServicesListener in 8.1
  • Adds symfony/service-contracts as an explicit dependency (was already transitive via http-kernel)

The 'services_resetter' service ID in PatchlevelEventSourcingExtension is unchanged — it remains the stable service ID across all versions.

Fixes #316

Symfony 8.1 moved ServicesResetter from HttpKernel to DependencyInjection,
breaking the constructor type hint. ResetInterface from symfony/service-contracts
works across Symfony 6.4, 7.x, and 8.x.

Fixes: patchlevel#316
@kochen
Copy link
Copy Markdown
Contributor Author

kochen commented Jun 1, 2026

Tested locally against a Symfony 8.1 application (PHP 8.5.6, patchlevel/event-sourcing-bundle 3.16.1): 470 integration tests, 2018 assertions — all green. The fix resolves the TypeError without any regressions.

@DavidBadura DavidBadura added this to the 3.17.0 milestone Jun 2, 2026
@DavidBadura DavidBadura added the bug Something isn't working label Jun 2, 2026
Copy link
Copy Markdown
Member

@DavidBadura DavidBadura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@DavidBadura DavidBadura merged commit 6f4ee05 into patchlevel:3.17.x Jun 2, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incompatible with Symfony 8.1: ResetServicesListener expects HttpKernel\ServicesResetter but container now injects DependencyInjection\ServicesResetter

2 participants