From f423ad0d6303ef42344b6a1069d2ac65305a3ec1 Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Mon, 19 Oct 2026 11:51:35 +0200 Subject: [PATCH] #56 - Mark the classes not meant to be extended @final and the infrastructure classes @internal - @final since 2.3 (final in 3.0): `GetTask`, `SetTask`, `AdapterRegistry`, `CleverAgeCacheProcessBundle`. Extending them triggers a deprecation with the Symfony DebugClassLoader. - Stay open: `AbstractCacheTask`, `Adapter` (extended by the applications, see `docs/reference/adapter.md`), `MissingAdapterException` (exceptions stay open, as in process-bundle). - @internal: `CleverAgeCacheProcessExtension`, `RegisterAdaptersPass`. - Same model as cleverage/process-bundle#279. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 1 + src/CleverAgeCacheProcessBundle.php | 3 +++ src/DependencyInjection/CleverAgeCacheProcessExtension.php | 2 ++ src/DependencyInjection/Compiler/RegisterAdaptersPass.php | 2 ++ src/Registry/AdapterRegistry.php | 2 ++ src/Task/GetTask.php | 2 ++ src/Task/SetTask.php | 2 ++ 7 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ed7e15..1ed3214 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Latest ------ ### Changes +* [#56](https://github.com/cleverage/cache-process-bundle/issues/56) Define the public API (Symfony BC promise, as [cleverage/process-bundle#279](https://github.com/cleverage/process-bundle/issues/279)): `GetTask`, `SetTask`, `AdapterRegistry` and `CleverAgeCacheProcessBundle` are marked `@final since 2.3`, they will be `final` in 3.0: extending them triggers a deprecation with the Symfony `DebugClassLoader`. `AbstractCacheTask`, `Adapter` (extended by the applications) and `MissingAdapterException` stay open. `CleverAgeCacheProcessExtension` and `RegisterAdaptersPass` are marked `@internal`. * [#55](https://github.com/cleverage/cache-process-bundle/issues/55) `CleverAgeCacheProcessExtension::findServices()` loads the service definition files with a glob pattern instead of a `Finder` (same files, as [cleverage/process-bundle#271](https://github.com/cleverage/process-bundle/issues/271)), `symfony/finder` is no longer required. Add tests. * [#53](https://github.com/cleverage/cache-process-bundle/issues/53) AdapterRegistry: the adapters are loaded lazily from a service locator indexed by code: an adapter is only instantiated when a task uses it (an error in an adapter that a process does not use no longer makes it fail). The code is given by the new `code` attribute of the `cleverage.cache.adapter` tag, or by the new `#[AsCacheAdapter(code: '...')]` attribute (autoconfiguration); it must be the one returned by `getCode()`. Duplicate or empty codes fail the container compilation. An adapter tagged without `code` is still registered eagerly, with `AdapterRegistry::addAdapter()`, which is deprecated (the `code` will be required in 3.0). New optional `AdapterRegistry` constructor argument (the locator), new `hasAdapter()` and `getAdapters()` methods. Require `symfony/service-contracts`. Update documentation, add tests. * [#51](https://github.com/cleverage/cache-process-bundle/issues/51) Use the PHP 8.3 to 8.5 functions through the Symfony polyfills ([cleverage/process-bundle#299](https://github.com/cleverage/process-bundle/issues/299)): require `symfony/polyfill-php83`, `symfony/polyfill-php84` and `symfony/polyfill-php85`. Rector is configured with the minimum supported PHP version (`withPhpVersion(PhpVersion::PHP_82)`, it used PHP 8.5 features) and `withPhpSets()` without explicit version, which applies the rules using a newer function when its polyfill is required (no change on the current code). Document it in `CONTRIBUTING.md`. diff --git a/src/CleverAgeCacheProcessBundle.php b/src/CleverAgeCacheProcessBundle.php index c88f0d7..32e0aed 100644 --- a/src/CleverAgeCacheProcessBundle.php +++ b/src/CleverAgeCacheProcessBundle.php @@ -17,6 +17,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; +/** + * @final since 2.3 + */ class CleverAgeCacheProcessBundle extends Bundle { /** diff --git a/src/DependencyInjection/CleverAgeCacheProcessExtension.php b/src/DependencyInjection/CleverAgeCacheProcessExtension.php index 5a54f39..bb9b109 100644 --- a/src/DependencyInjection/CleverAgeCacheProcessExtension.php +++ b/src/DependencyInjection/CleverAgeCacheProcessExtension.php @@ -24,6 +24,8 @@ * This is the class that loads and manages your bundle configuration. * * @see https://symfony.com/doc/current/bundles/extension.html + * + * @internal */ class CleverAgeCacheProcessExtension extends Extension { diff --git a/src/DependencyInjection/Compiler/RegisterAdaptersPass.php b/src/DependencyInjection/Compiler/RegisterAdaptersPass.php index f808995..16d1e69 100644 --- a/src/DependencyInjection/Compiler/RegisterAdaptersPass.php +++ b/src/DependencyInjection/Compiler/RegisterAdaptersPass.php @@ -22,6 +22,8 @@ /** * Registers the `cleverage.cache.adapter` tagged services in the adapter registry: in a service locator indexed by the * `code` attribute of the tag (lazy), or, without `code` (deprecated), with an addAdapter() call (eager). + * + * @internal */ class RegisterAdaptersPass implements CompilerPassInterface { diff --git a/src/Registry/AdapterRegistry.php b/src/Registry/AdapterRegistry.php index 82a3ca7..cad7eec 100644 --- a/src/Registry/AdapterRegistry.php +++ b/src/Registry/AdapterRegistry.php @@ -23,6 +23,8 @@ * The adapter services are fetched lazily from a service locator indexed by code (`code` attribute of the * `cleverage.cache.adapter` tag, or `#[AsCacheAdapter]`, see RegisterAdaptersPass): an adapter is only instantiated * when it is used. + * + * @final since 2.3 */ class AdapterRegistry { diff --git a/src/Task/GetTask.php b/src/Task/GetTask.php index bbe4b64..9eab113 100644 --- a/src/Task/GetTask.php +++ b/src/Task/GetTask.php @@ -24,6 +24,8 @@ * key: string, * on_miss: string * } + * + * @final since 2.3 */ class GetTask extends AbstractCacheTask { diff --git a/src/Task/SetTask.php b/src/Task/SetTask.php index 3ed3822..145454d 100644 --- a/src/Task/SetTask.php +++ b/src/Task/SetTask.php @@ -25,6 +25,8 @@ * value: mixed, * expires_after: int|null * } + * + * @final since 2.3 */ class SetTask extends AbstractCacheTask {