From 59b34b0399220cbac7223e87948f60dd0eef0290 Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Mon, 19 Oct 2026 11:51:40 +0200 Subject: [PATCH] #62 - Mark the classes not meant to be extended @final and the infrastructure classes @internal - @final since 3.3 (final in 4.0): `RequestTask`, `ClientRegistry`, `CleverAgeRestProcessBundle`. Extending them triggers a deprecation with the Symfony DebugClassLoader. - Stay open: `Client` (extended by the applications, see `docs/reference/client.md`), the exceptions (as in process-bundle). - @internal: `CleverAgeRestProcessExtension`, `RegisterClientsPass`. - Same model as cleverage/process-bundle#279. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 1 + src/CleverAgeRestProcessBundle.php | 3 +++ src/DependencyInjection/CleverAgeRestProcessExtension.php | 3 +++ src/DependencyInjection/Compiler/RegisterClientsPass.php | 2 ++ src/Registry/ClientRegistry.php | 2 ++ src/Task/RequestTask.php | 2 ++ 6 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d9eb80..102a5af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Latest ------ ### Changes +* [#62](https://github.com/cleverage/rest-process-bundle/issues/62) Define the public API (Symfony BC promise, as [cleverage/process-bundle#279](https://github.com/cleverage/process-bundle/issues/279)): `RequestTask`, `ClientRegistry` and `CleverAgeRestProcessBundle` are marked `@final since 3.3`, they will be `final` in 4.0: extending them triggers a deprecation with the Symfony `DebugClassLoader`. `Client` (extended by the applications) and the exceptions stay open. `CleverAgeRestProcessExtension` and `RegisterClientsPass` are marked `@internal`. * [#58](https://github.com/cleverage/rest-process-bundle/issues/58) ClientRegistry: the clients are loaded lazily from a service locator indexed by code: a client is only instantiated when a task uses it (an error in a client that a process does not use no longer makes it fail). The code is given by the new `code` attribute of the `cleverage.rest.client` tag, or by the new `#[AsRestClient(code: '...')]` attribute (autoconfiguration); it must be the one returned by `getCode()`. Duplicate or empty codes fail the container compilation. A client tagged without `code` is still registered eagerly, with `ClientRegistry::addClient()`, which is deprecated (the `code` will be required in 4.0). New optional `ClientRegistry` constructor argument (the locator); `ClientRegistry` is autowirable by its class name. Require `symfony/service-contracts`. Update documentation, add tests. * [#56](https://github.com/cleverage/rest-process-bundle/issues/56) Require `symfony/polyfill-php83`, `symfony/polyfill-php84` and `symfony/polyfill-php85` ([cleverage/process-bundle#299](https://github.com/cleverage/process-bundle/issues/299)): the functions of PHP 8.3 to 8.5 can be used while supporting PHP 8.2. Rector targets PHP 8.2 (`withPhpVersion()`, `withPhpSets()` read from `composer.json`) and applies the rules using a newer function when its polyfill is required (no change needed in the current code). * [#52](https://github.com/cleverage/rest-process-bundle/issues/52) Give a code to the task ([cleverage/process-bundle#91](https://github.com/cleverage/process-bundle/issues/91)): `rest_request` (`task: rest_request`, with `cleverage/process-bundle` 5.4 or later, referencing it by `service` being deprecated there). The task has its class name as service id; fetching it directly from the service container is deprecated (`container.private`), it will be private in 4.0. The former id `cleverage_rest_process.task.request` is a deprecated alias, removed in 4.0. Update documentation, add tests. diff --git a/src/CleverAgeRestProcessBundle.php b/src/CleverAgeRestProcessBundle.php index 34e31cb..093d8b7 100644 --- a/src/CleverAgeRestProcessBundle.php +++ b/src/CleverAgeRestProcessBundle.php @@ -17,6 +17,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; +/** + * @final since 3.3 + */ class CleverAgeRestProcessBundle extends Bundle { /** diff --git a/src/DependencyInjection/CleverAgeRestProcessExtension.php b/src/DependencyInjection/CleverAgeRestProcessExtension.php index 66c4401..e1dfc74 100644 --- a/src/DependencyInjection/CleverAgeRestProcessExtension.php +++ b/src/DependencyInjection/CleverAgeRestProcessExtension.php @@ -21,6 +21,9 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Finder\Finder; +/** + * @internal + */ class CleverAgeRestProcessExtension extends Extension { public function load(array $configs, ContainerBuilder $container): void diff --git a/src/DependencyInjection/Compiler/RegisterClientsPass.php b/src/DependencyInjection/Compiler/RegisterClientsPass.php index 481f10e..e3ca91b 100644 --- a/src/DependencyInjection/Compiler/RegisterClientsPass.php +++ b/src/DependencyInjection/Compiler/RegisterClientsPass.php @@ -22,6 +22,8 @@ /** * Registers the `cleverage.rest.client` tagged services in the client registry: in a service locator indexed by the * `code` attribute of the tag (lazy), or, without `code` (deprecated), with an addClient() call (eager). + * + * @internal */ class RegisterClientsPass implements CompilerPassInterface { diff --git a/src/Registry/ClientRegistry.php b/src/Registry/ClientRegistry.php index bf99bda..684816b 100644 --- a/src/Registry/ClientRegistry.php +++ b/src/Registry/ClientRegistry.php @@ -23,6 +23,8 @@ * The client services are fetched lazily from a service locator indexed by code (`code` attribute of the * `cleverage.rest.client` tag, or `#[AsRestClient]`, see RegisterClientsPass): a client is only instantiated when it * is used. + * + * @final since 3.3 */ class ClientRegistry { diff --git a/src/Task/RequestTask.php b/src/Task/RequestTask.php index e6227c0..a553c1c 100644 --- a/src/Task/RequestTask.php +++ b/src/Task/RequestTask.php @@ -50,6 +50,8 @@ * 'expects': string, * 'data': array|string|null * } + * + * @final since 3.3 */ class RequestTask extends AbstractConfigurableTask {