Skip to content

Give every service its class name as id - #36

Merged
loevgaard merged 1 commit into
2.xfrom
service-class-name-ids
Nov 30, 2026
Merged

loevgaard merged 1 commit into
2.xfrom
service-class-name-ids

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Closes #32. Implements ADR-0004 (#35).

Summary

Every service has its class name as id, and each interface aliases its implementation directly.

 ClientContextInterface
-  → setono_client.client_context.default
-    → setono_client.client_context.cookie_based
+  → Setono\ClientBundle\Context\CookieBasedClientContext
   decorated by
-    setono_client.client_context.cached (-1024, inner: setono_client.client_context.cached.inner)
+    Setono\ClientBundle\Context\CachedClientContext (-1024, inner: .inner)

 MetadataStoreInterface
-  → setono_client.metadata_store.default
-    → setono_client.metadata_store.doctrine_orm_based
+  → Setono\ClientBundle\MetadataStore\DoctrineOrmBasedMetadataStore

ClientCookieJar, ClientValueResolver, StoreCookieSubscriber and StoreMetadataSubscriber get their class names as ids the same way. The definitions no longer have a class attribute, because Symfony takes the class from the id.

The docs and tests name only the interfaces as decoration targets. The test app's HeaderClientContext, which decorated setono_client.client_context.default, is gone, along with its two tests. UPGRADE-2.0.md opens with a ## Service ids section that maps the 1.x ids to the new ones.

Evidence

  • Before: SetonoClientExtensionTest, with assertions for the ::class ids, fails: The container builder has no service "Setono\ClientBundle\Context\CachedClientContext" (2 failures, 1 error).
    After: it passes. So do the full suite (149 tests), PHPStan, ECS and composer validate --strict. Infection kills all 95 mutants (100% MSI, 100% covered MSI).
  • The functional suite still gets CachedClientContext and the app's decorated store when it autowires the interfaces.
  • grep -rnE "setono_client\.(client_context|cookie\.client_cookie_jar|controller|event_subscriber|metadata_store)" config src tests README.md CLAUDE.md finds nothing.

Merge Danger

Door: two-way

2.0.0 isn't released, so a revert brings the old ids back. Once 2.0.0 ships, the ids are public.

Blast Radius: consumers

An app on 2.x that names a setono_client.* service id or a .default alias fails to compile until it uses the class name or the interface. Apps can now autowire the concrete classes. The README warns that injecting CookieBasedClientContext skips CachedClientContext, and injecting DoctrineOrmBasedMetadataStore skips the app's decorators of MetadataStoreInterface.

Every service the bundle defines now has its class name as id, and
ClientContextInterface and MetadataStoreInterface alias their
implementations directly, without the setono_client.*.default aliases.
CachedClientContext refers to its inner service as .inner.

The interfaces are the only decoration targets the docs and tests name,
so the test app's HeaderClientContext and its two tests are gone.
UPGRADE-2.0.md maps the 1.x ids to the new ones.

Closes #32
Comment thread config/services.xml Resolved
@loevgaard
loevgaard merged commit 9b13fad into 2.x Nov 30, 2026
19 checks passed
@loevgaard
loevgaard deleted the service-class-name-ids branch November 30, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use fully qualified class names as service ids

1 participant