diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a04902..c8165776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Latest * [#292](https://github.com/cleverage/process-bundle/issues/292) Reject the process configuration errors deprecated during v5: the `errors` task configuration key is removed (use `error_outputs`), with `TaskConfiguration::getErrors()` and `$logErrors`; an unknown `error_strategy` (#310) and an unknown task reference (#426) fail the container compilation; a task listed several times in the `outputs` / `error_outputs` of a task throws an `InvalidProcessConfigurationException` (#414); a shared service used by several tasks of a process fails the container compilation (#382). The former names of the codes with a dash, with underscores, are no longer found (#412, #475): processes, tasks, generic transformers, transformer codes and contextual options of the generic transformers; `DeprecatedCodeAliases` and the second argument of the `TransformerRegistry` constructor are removed (see `UPGRADE.md`). Update documentation and tests. * [#292](https://github.com/cleverage/process-bundle/issues/292) Remove the classes, methods and options deprecated during v5: `ProcessState::getReturnCode()` / `setReturnCode()` (#503), the `cleverage_process.event_listener.data_queue` service and `DataQueueEventListener` (#311), `CheckSerializerCompilerPass`, the `KernelInterface` argument and the `$kernel` / `$logDir` properties of `CommandRunnerTask`, `ProcessLauncherTask` and `SubprocessInstance` (#318), the `process_options` option of the `process_launcher` task (see `UPGRADE.md`). Update documentation and tests. * [#292](https://github.com/cleverage/process-bundle/issues/292) Apply the behaviours announced by the deprecations of v5: an exception thrown by the `initialize()` of a task makes the process fail before any task is executed, with a `ProcessFailedException` (#222); the `event_dispatcher` task no longer dispatches its event under the class name of the event too when `event_name` is set (#189); a target property of an array destination that is neither a simple property name nor an index notation (`address.city`) throws an `UnexpectedValueException` in the `mapping` transformer (#117); the `additional_parameters` option of the `callback` transformer is removed, use `right_parameters`; a negative `flush_every` of the `counter` task is rejected (#491) (see `UPGRADE.md`). Update documentation and tests. +* [#279](https://github.com/cleverage/process-bundle/issues/279) The 109 classes marked `@final since 5.4` are `final` (engine, registries, models, configurations, events, `CleverAgeProcessBundle`, concrete tasks and transformers): they can no longer be extended nor doubled by PHPUnit. The services of the bundle are typed on `ProcessManagerInterface`, `ProcessConfigurationRegistryInterface` and `TransformerRegistryInterface`, so that a decorator is injected everywhere; `ProcessManagerInterface` declares `getProcessHistory()` and `getTaskConfiguration()`, `ProcessConfigurationRegistryInterface` declares `getProcessCodes()`, and both extend `ResetInterface` (a decorator receives the `kernel.reset` tag and must delegate `reset()`). `PregFilterTransformer::transform()` returns `?string`, the `$transformerRegistry` property of `TransformerTrait` is typed on `TransformerRegistryInterface`, `SplFile::readLine()` no longer has its unused `$length` parameter (see `UPGRADE.md`). Update documentation and tests. ## Changes * [#428](https://github.com/cleverage/process-bundle/issues/428) Tests on PHPUnit 12.5 and 13 (PHPUnit 10 and 11 dropped), with the lowest dependencies on PHP 8.3 and 8.5. diff --git a/UPGRADE.md b/UPGRADE.md index 208efca6..49929de7 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -28,23 +28,22 @@ Flex recipe (`config/packages/clever_age_process.yaml`) is free, you can rename ### Typed class constants -The class constants of the bundle are typed. A class extending a class of the bundle and redeclaring one of its -protected constants must declare it with the same type: - -- `string`: `ProcessHelpCommand::CHAR_*` (`protected const string CHAR_NODE = '●';`); -- `int`: `ProcessHelpCommand::BRANCH_SIZE` / `INDENT_SIZE`, `ProcessManager::EXECUTE_*`, - `ProcessLauncherTask::STOP_TIMEOUT` (`protected const int INDENT_SIZE = 2;`); -- `array`: `ArrayMergeTask::MERGE_FUNC`. +The class constants of the bundle are typed. A class extending `ProcessHelpCommand` (internal) and redeclaring one of +its protected constants must declare it with the same type: `ProcessHelpCommand::CHAR_*` are `string` +(`protected const string CHAR_NODE = '●';`), `ProcessHelpCommand::BRANCH_SIZE` / `INDENT_SIZE` are `int`. The other +classes declaring typed constants are `final` (see [Final classes](#final-classes)). ### Narrowed native types Native types that were never `null` in practice no longer accept it. A class extending a class of the bundle and overriding one of these members must declare the narrowed type (a nullable type is a fatal error): -- `AbstractConfigurableTask::getOptions()` and `ProcessState::getContextualizedOptions()` return `array` (instead of - `?array`): `protected function getOptions(ProcessState $state): array`; -- `CsvResource::$lineNumber` is an `int` (instead of `?int`), `ProcessHistory::$startDate` a `\DateTimeInterface` - (instead of `?\DateTimeInterface`). +- `AbstractConfigurableTask::getOptions()` returns `array` (instead of `?array`): + `protected function getOptions(ProcessState $state): array`; +- `CsvResource::$lineNumber` is an `int` (instead of `?int`). + +`ProcessState::getContextualizedOptions()` returns `array` and `ProcessHistory::$startDate` is a `\DateTimeInterface` +(both classes are `final`): remove a `?? []` or a `null` check on them, now useless. ### `array_first` transformer @@ -97,10 +96,9 @@ The code of a transformer is only given by the `code` attribute of its `cleverag - `TransformerRegistryInterface` declares `getTransformerCodes()` (the codes, without instantiating the transformers): implement it in your own implementations; - `RegistryCompilerPass` is removed (deprecated since 5.4), it was no longer used by the bundle; -- a class extending `TransformerRegistry` (`@final` since 5.4) must declare the `$locator` property as non-nullable - (`protected ServiceProviderInterface $locator`), and the transformers it adds to `$transformers` itself are no longer - given by `hasTransformer()`, `getTransformer()` and `getTransformers()`, which only read the locator: register them in - the locator. +- `TransformerRegistry` only reads its locator: a transformer must be registered in the locator (a tagged service) to be + given by `hasTransformer()`, `getTransformer()` and `getTransformers()`; the class is `final` (see + [Final classes](#final-classes)). ### Tasks and service container @@ -197,6 +195,50 @@ The former names of the codes with a dash, with underscores instead of dashes, a - a negative `flush_every` option of the `counter` task is rejected with an `InvalidOptionsException` (it worked as its absolute value, deprecated since 5.10): use a positive integer. +### Final classes + +The classes marked `@final since 5.4` are `final`: the engine (`ProcessManager`, `ProcessConfigurationRegistry`, +`TransformerRegistry`, `ContextualOptionResolver`), the models (`ProcessState`, `ProcessHistory`, the configurations, +the events), `SubprocessInstance`, the files of `Filesystem` (`SplFile`, `CsvFile`, `JsonStreamFile`, `XmlFile`), +`ConstraintLoader`, `CleverAgeProcessBundle` and the concrete tasks and transformers. A class extending one of them +fails with `Class ... cannot extend final class ...`, and PHPUnit can no longer create a mock or a stub of them: + +- write your own task (extending `AbstractConfigurableTask`) or transformer, and inject the services of the bundle it + needs, or decorate a service of the bundle; +- type your services and your test doubles on the interfaces (`ProcessManagerInterface`, + `ProcessConfigurationRegistryInterface`, `TransformerRegistryInterface`, `TaskRegistryInterface`); the services of + the bundle are typed on them, so a decorator implementing the interface is injected everywhere; +- build a real `ProcessState` in your tests instead of a double: + `new ProcessState($processConfiguration, new ProcessHistory($processConfiguration))`; +- autowire the services by their interface, not by their class: the aliases on the classes (`ProcessManager`, + `ProcessConfigurationRegistry`, `TransformerRegistry`, `TaskRegistry`) still exist, but once the service is decorated + they give the decorator, which fails a parameter typed on the class with a `TypeError`; +- `ContextualOptionResolver` has no interface: it cannot be decorated (the process manager, `ProcessState` and the + `generic` transformers are typed on it). + +`ProcessManagerInterface` declares `getProcessHistory()` and `getTaskConfiguration()` (read by the Monolog processors), +and `ProcessConfigurationRegistryInterface` declares `getProcessCodes()` (the codes, without resolving the +configurations). Both interfaces extend `Symfony\Contracts\Service\ResetInterface`: the `kernel.reset` tag of the +service moves to its decorator, so `reset()` is called on the decorator (e.g. between two messages of a worker). +Implement these methods in your own implementations; a decorator delegates them to the decorated service, `reset()` +included, otherwise the locks and the states of the processes are kept from one message to the next: + +```php +public function reset(): void +{ + $this->inner->reset(); +} +``` + +Other signatures: + +- `PregFilterTransformer::transform()` returns `?string` (instead of `array|string|null`, the subject is always a + string); +- the `$transformerRegistry` property of `TransformerTrait` is a `?TransformerRegistryInterface` (instead of + `?TransformerRegistry`): a class using the trait and redeclaring the property must use the new type; +- `SplFile::readLine()` no longer has the unused `$length` parameter: remove the argument (a positional one is + ignored, a named one fails with `Unknown named parameter $length`). + ## v5.10 ### Stop strategy and error branch ending on a stop diff --git a/docs/01-quick_start.md b/docs/01-quick_start.md index 92c1c1d8..a8dbb0e1 100644 --- a/docs/01-quick_start.md +++ b/docs/01-quick_start.md @@ -295,7 +295,7 @@ Example: ### Contextual values -Values passed with `--context` (or with the `$context` argument of `ProcessManager::execute()`, see +Values passed with `--context` (or with the `$context` argument of `ProcessManagerInterface::execute()`, see [executing a process from PHP](04-advanced_workflow.md#executing-a-process-from-php)) are available in every task of the process: - in the task options, a string `{{ key }}` is replaced by the value of the `key` context entry. If the whole option diff --git a/docs/03-custom_tasks.md b/docs/03-custom_tasks.md index 556bc4ef..938ec99a 100644 --- a/docs/03-custom_tasks.md +++ b/docs/03-custom_tasks.md @@ -282,13 +282,14 @@ services: - { name: cleverage.transformer, code: app_vat } ``` -Once properly set up, they are registered in the `CleverAge\ProcessBundle\Registry\TransformerRegistry` (used by the -`TransformerTask` and every transformer using a sub-list of transformers) under their code, in a service locator: a -transformer is only instantiated when a process uses it. Two transformers cannot share the same code, and a transformer -tagged without `code` (e.g. autoconfigured without the attribute) cannot be registered: in both cases, the container -compilation fails. A service tagged with several codes is registered under each of them. - -`TransformerRegistry::getTransformerCodes()` gives the registered codes without instantiating the transformers. +Once properly set up, they are registered in the transformer registry +(`CleverAge\ProcessBundle\Registry\TransformerRegistryInterface`, used by the `TransformerTask` and every transformer +using a sub-list of transformers) under their code, in a service locator: a transformer is only instantiated when a +process uses it. Two transformers cannot share the same code, and a transformer tagged without `code` (e.g. +autoconfigured without the attribute) cannot be registered: in both cases, the container compilation fails. A service +tagged with several codes is registered under each of them. + +`TransformerRegistryInterface::getTransformerCodes()` gives the registered codes without instantiating the transformers. When creating a new transformer for your project, use an internal prefix in your codes to avoid conflicts with potential standard additions. diff --git a/docs/04-advanced_workflow.md b/docs/04-advanced_workflow.md index a98033f2..a3332940 100644 --- a/docs/04-advanced_workflow.md +++ b/docs/04-advanced_workflow.md @@ -4,7 +4,8 @@ Advanced Workflow ## Process execution flow When a process is executed (with the `cleverage:process:execute` command or with -`CleverAge\ProcessBundle\Manager\ProcessManager::execute($processCode, $input, $context)`), the process manager: +`CleverAge\ProcessBundle\Manager\ProcessManagerInterface::execute($processCode, $input, $context)`), the process +manager: 1. dispatches the `cleverage_process.start` event 2. checks the process: circular dependencies are forbidden, and the `entry_point` / `end_point` tasks must be part of @@ -42,10 +43,13 @@ own tasks and transformers. The reference pages name these exceptions without th ### Executing a process from PHP The process manager service (`cleverage_process.manager.process`, private) can be autowired by its interface, -`CleverAge\ProcessBundle\Manager\ProcessManagerInterface` (or by its class, `ProcessManager`), or injected -explicitly. Type your services on the interface: the class will be `final` in v6.0 (the services of the bundle will -then be typed on the interfaces, so that they can be decorated). The registries have their interface too: `ProcessConfigurationRegistryInterface`, -`TransformerRegistryInterface` and `TaskRegistryInterface` (namespace `CleverAge\ProcessBundle\Registry`). +`CleverAge\ProcessBundle\Manager\ProcessManagerInterface`, or injected explicitly. Type your services on the interface: +the class is `final`, and the services of the bundle are typed on the interfaces, so that they can be decorated (the +alias on the class `ProcessManager` gives the decorator too, which fails a parameter typed on the class). A decorator of +the process manager or of the process configuration registry receives their `kernel.reset` tag: its `reset()` method +(required by the interfaces) must call the one of the decorated service. The registries have their interface too: +`ProcessConfigurationRegistryInterface`, `TransformerRegistryInterface` and `TaskRegistryInterface` (namespace +`CleverAge\ProcessBundle\Registry`). ```yaml # config/services.yaml diff --git a/docs/05-good_practices.md b/docs/05-good_practices.md index 040331bf..ff382261 100644 --- a/docs/05-good_practices.md +++ b/docs/05-good_practices.md @@ -108,15 +108,14 @@ The classes meant to be extended are the abstract ones (`AbstractConfigurableTas a base by other tasks (`FileReaderTask`, `LineReaderTask`, `FolderBrowserTask`, `CsvReaderTask`, `InputCsvReaderTask` and `Filesystem\CsvResource`). -The other classes are marked `@final since 5.4`, they will be `final` in v6.0: the engine (`ProcessManager`, the -registries, `ContextualOptionResolver`), the models (`ProcessState`, the configurations, the events) and the concrete -tasks and transformers. Extending one of them triggers a deprecation (with the Symfony `DebugClassLoader`, enabled by -`symfony/error-handler` in debug mode). Instead: +The other classes are `final`: the engine (`ProcessManager`, the registries, `ContextualOptionResolver`), the models +(`ProcessState`, the configurations, the events) and the concrete tasks and transformers. Instead of extending them: - write your own task (extending `AbstractConfigurableTask`) or transformer, and inject the services of the bundle you need; -- [decorate](https://symfony.com/doc/current/service_container/service_decoration.html) a service, or listen to the - process [events](04-advanced_workflow.md); +- [decorate](https://symfony.com/doc/current/service_container/service_decoration.html) a service having an + interface (`ProcessManagerInterface`, the registries; not `ContextualOptionResolver`), or listen to the process + [events](04-advanced_workflow.md); - chain existing tasks and transformers in the process configuration. The classes marked `@internal` (the dependency injection compiler passes, the commands, the event listeners, the Monolog diff --git a/docs/06-testing.md b/docs/06-testing.md index 3b926b91..2b18cc66 100644 --- a/docs/06-testing.md +++ b/docs/06-testing.md @@ -93,7 +93,8 @@ For iterable tasks, call `execute()` then `next()` in a loop; for blocking tasks ## Functional testing of processes The best way to test a whole workflow is to execute the process, like the console command does, with the process -manager. Its service id is `cleverage_process.manager.process` (class `CleverAge\ProcessBundle\Manager\ProcessManager`); +manager. Its service id is `cleverage_process.manager.process` (interface +`CleverAge\ProcessBundle\Manager\ProcessManagerInterface`); it is a private service, available through the test container of a `KernelTestCase`: ```php @@ -143,7 +144,7 @@ cleverage_process: ```php namespace App\Tests\Process; -use CleverAge\ProcessBundle\Manager\ProcessManager; +use CleverAge\ProcessBundle\Manager\ProcessManagerInterface; use PHPUnit\Framework\Attributes\CoversNothing; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -153,7 +154,7 @@ class VatProcessTest extends KernelTestCase public function testProcess(): void { self::bootKernel(); - /** @var ProcessManager $processManager */ + /** @var ProcessManagerInterface $processManager */ $processManager = self::getContainer()->get('cleverage_process.manager.process'); $result = $processManager->execute('test.app.vat', 100, ['rate' => 0.055]); diff --git a/docs/reference/01-process_definition.md b/docs/reference/01-process_definition.md index c195016f..16f72f38 100644 --- a/docs/reference/01-process_definition.md +++ b/docs/reference/01-process_definition.md @@ -59,8 +59,8 @@ them: the former name is no longer found since v6.0. empty. **entry_point**: optional task code (default is none) that will receive the process input (`--input` option of the -execute command, or `$input` argument of `ProcessManager::execute()`). The referenced task cannot have ancestors, and -must be in the [main branch](#main-branch) of the process. +execute command, or `$input` argument of `ProcessManagerInterface::execute()`). The referenced task cannot have +ancestors, and must be in the [main branch](#main-branch) of the process. **end_point**: optional task code (default is none) whose last output will be returned as the process output. It must be in the main branch of the process. An ignored output (the task is skipped, filters its input or fails with the diff --git a/docs/reference/tasks/iterable_batch_task.md b/docs/reference/tasks/iterable_batch_task.md index 2538923d..267a9b95 100644 --- a/docs/reference/tasks/iterable_batch_task.md +++ b/docs/reference/tasks/iterable_batch_task.md @@ -3,8 +3,8 @@ IterableBatchTask Buffers inputs and, every `batch_count` inputs, iterates over the buffer to output its elements one by one. Remaining elements are output (one by one as well) when the task is flushed, at the end of the upstream iteration. It is mainly -an example task: it is not really useful as is, but its `processInput()` method can be overridden to customize how -each input is transformed before being buffered. +an example task, not really useful as is. The class is `final`: to transform each input before it is buffered, put a +`transformer` task before it, or write your own task (extending `AbstractConfigurableTask`). Task reference -------------- diff --git a/docs/reference/traits/transformer_trait.md b/docs/reference/traits/transformer_trait.md index 176ac5cd..bb225306 100644 --- a/docs/reference/traits/transformer_trait.md +++ b/docs/reference/traits/transformer_trait.md @@ -48,7 +48,8 @@ transformers: ## Usage -* Set the `$transformerRegistry` property with the `TransformerRegistry` service (e.g. in the constructor) +* Set the `$transformerRegistry` property with the transformer registry (`TransformerRegistryInterface`, e.g. in the + constructor) * Call `TransformerTrait::configureTransformersOptions` with your own `OptionsResolver`. You can change `$optionName` if you want a custom option name * Call `TransformerTrait::applyTransformers` with the resolved transformer option (i.e. `$options['transformers']`) diff --git a/src/CleverAgeProcessBundle.php b/src/CleverAgeProcessBundle.php index 39dc9c99..2007c6b7 100644 --- a/src/CleverAgeProcessBundle.php +++ b/src/CleverAgeProcessBundle.php @@ -37,10 +37,7 @@ use Symfony\Component\HttpKernel\Bundle\AbstractBundle; use Symfony\Component\Lock\LockFactory; -/** - * @final since 5.4 - */ -class CleverAgeProcessBundle extends AbstractBundle +final class CleverAgeProcessBundle extends AbstractBundle { private const array LOG_LEVELS = [ LogLevel::EMERGENCY, @@ -84,7 +81,7 @@ public function getContainerExtension(): ExtensionInterface } /** - * The root directory of the bundle, also for a class extending it (AbstractBundle guesses it from the class file). + * The root directory of the bundle (AbstractBundle guesses it from the class file). */ #[\Override] public function getPath(): string @@ -133,7 +130,6 @@ public function configure(DefinitionConfigurator $definition): void #[\Override] public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void { - // Absolute path: a relative one would be resolved from the directory of a class extending the bundle $container->import(__DIR__.'/../config/services/*.php'); $builder->registerForAutoconfiguration(ProcessStopCheckerInterface::class) diff --git a/src/Command/ExecuteProcessCommand.php b/src/Command/ExecuteProcessCommand.php index a0d6fe32..b874fb5c 100644 --- a/src/Command/ExecuteProcessCommand.php +++ b/src/Command/ExecuteProcessCommand.php @@ -18,8 +18,8 @@ use CleverAge\ProcessBundle\Event\ConsoleProcessEvent; use CleverAge\ProcessBundle\Exception\InvalidArgumentException; use CleverAge\ProcessBundle\Filesystem\JsonStreamFile; -use CleverAge\ProcessBundle\Manager\ProcessManager; -use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; +use CleverAge\ProcessBundle\Manager\ProcessManagerInterface; +use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistryInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -47,9 +47,9 @@ class ExecuteProcessCommand extends Command final public const string OUTPUT_FORMAT_JSON = 'json-stream'; public function __construct( - protected ProcessManager $processManager, + protected ProcessManagerInterface $processManager, protected EventDispatcherInterface $eventDispatcher, - protected ProcessConfigurationRegistry $processRegistry, + protected ProcessConfigurationRegistryInterface $processRegistry, ) { parent::__construct(); } diff --git a/src/Command/ListProcessCommand.php b/src/Command/ListProcessCommand.php index b7ec1d93..fa95a58e 100644 --- a/src/Command/ListProcessCommand.php +++ b/src/Command/ListProcessCommand.php @@ -14,7 +14,7 @@ namespace CleverAge\ProcessBundle\Command; use CleverAge\ProcessBundle\Configuration\ProcessConfiguration; -use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; +use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistryInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -30,7 +30,7 @@ class ListProcessCommand extends Command { public function __construct( - protected ProcessConfigurationRegistry $processConfigRegistry, + protected ProcessConfigurationRegistryInterface $processConfigRegistry, ) { parent::__construct(); } diff --git a/src/Command/ProcessHelpCommand.php b/src/Command/ProcessHelpCommand.php index 991b9bbe..100ef8e5 100644 --- a/src/Command/ProcessHelpCommand.php +++ b/src/Command/ProcessHelpCommand.php @@ -21,7 +21,7 @@ use CleverAge\ProcessBundle\Model\FlushableTaskInterface; use CleverAge\ProcessBundle\Model\IterableTaskInterface; use CleverAge\ProcessBundle\Model\TaskInterface; -use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; +use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistryInterface; use CleverAge\ProcessBundle\Registry\TaskRegistryInterface; use CleverAge\ProcessBundle\Task\Process\ProcessExecutorTask; use CleverAge\ProcessBundle\Task\Process\ProcessLauncherTask; @@ -64,7 +64,7 @@ class ProcessHelpCommand extends Command protected const int INDENT_SIZE = 4; public function __construct( - protected ProcessConfigurationRegistry $processConfigRegistry, + protected ProcessConfigurationRegistryInterface $processConfigRegistry, protected TaskRegistryInterface $taskRegistry, ) { parent::__construct(); diff --git a/src/Configuration/ProcessConfiguration.php b/src/Configuration/ProcessConfiguration.php index 4198be17..e881cbd4 100644 --- a/src/Configuration/ProcessConfiguration.php +++ b/src/Configuration/ProcessConfiguration.php @@ -19,10 +19,8 @@ /** * Holds the processes configuration to launch a task. - * - * @final since 5.4 */ -class ProcessConfiguration +final class ProcessConfiguration { /** * @var list>|null diff --git a/src/Configuration/TaskConfiguration.php b/src/Configuration/TaskConfiguration.php index fd6b244d..216859ef 100644 --- a/src/Configuration/TaskConfiguration.php +++ b/src/Configuration/TaskConfiguration.php @@ -19,14 +19,12 @@ /** * Represents a task configuration inside a process. - * - * @final since 5.4 */ -class TaskConfiguration +final class TaskConfiguration { - final public const string STRATEGY_SKIP = 'skip'; + public const string STRATEGY_SKIP = 'skip'; - final public const string STRATEGY_STOP = 'stop'; + public const string STRATEGY_STOP = 'stop'; protected ?TaskInterface $task = null; diff --git a/src/Context/ContextualOptionResolver.php b/src/Context/ContextualOptionResolver.php index 4e066f8c..e102a58a 100644 --- a/src/Context/ContextualOptionResolver.php +++ b/src/Context/ContextualOptionResolver.php @@ -13,10 +13,7 @@ namespace CleverAge\ProcessBundle\Context; -/** - * @final since 5.4 - */ -class ContextualOptionResolver +final class ContextualOptionResolver { /** * Basic value inference diff --git a/src/Event/ConsoleProcessEvent.php b/src/Event/ConsoleProcessEvent.php index e25efcdf..57b411c3 100644 --- a/src/Event/ConsoleProcessEvent.php +++ b/src/Event/ConsoleProcessEvent.php @@ -19,10 +19,8 @@ /** * Event object used during CLI process manipulation. - * - * @final since 5.4 */ -class ConsoleProcessEvent extends Event +final class ConsoleProcessEvent extends Event { /** * @param array $processContext diff --git a/src/Event/EventDispatcherTaskEvent.php b/src/Event/EventDispatcherTaskEvent.php index c598c0fa..5fab46e9 100644 --- a/src/Event/EventDispatcherTaskEvent.php +++ b/src/Event/EventDispatcherTaskEvent.php @@ -16,10 +16,7 @@ use CleverAge\ProcessBundle\Model\ProcessState; use Symfony\Contracts\EventDispatcher\Event; -/** - * @final since 5.4 - */ -class EventDispatcherTaskEvent extends Event +final class EventDispatcherTaskEvent extends Event { public function __construct( protected ProcessState $state, diff --git a/src/Event/ProcessEvent.php b/src/Event/ProcessEvent.php index fa8e6a47..e9cfa85d 100644 --- a/src/Event/ProcessEvent.php +++ b/src/Event/ProcessEvent.php @@ -17,16 +17,14 @@ /** * Event object for process start/stop/fail. - * - * @final since 5.4 */ -class ProcessEvent extends Event +final class ProcessEvent extends Event { - final public const string EVENT_PROCESS_STARTED = 'cleverage_process.start'; + public const string EVENT_PROCESS_STARTED = 'cleverage_process.start'; - final public const string EVENT_PROCESS_ENDED = 'cleverage_process.end'; + public const string EVENT_PROCESS_ENDED = 'cleverage_process.end'; - final public const string EVENT_PROCESS_FAILED = 'cleverage_process.fail'; + public const string EVENT_PROCESS_FAILED = 'cleverage_process.fail'; /** * @param array $processContext diff --git a/src/Filesystem/CsvFile.php b/src/Filesystem/CsvFile.php index b418547c..4c2e2ca5 100644 --- a/src/Filesystem/CsvFile.php +++ b/src/Filesystem/CsvFile.php @@ -18,10 +18,8 @@ /** * Read and write CSV files through a simple API. - * - * @final since 5.4 */ -class CsvFile extends CsvResource +final class CsvFile extends CsvResource { /** * @param string $filePath Also accept a resource diff --git a/src/Filesystem/JsonStreamFile.php b/src/Filesystem/JsonStreamFile.php index 9f7a81ca..0ae411c6 100644 --- a/src/Filesystem/JsonStreamFile.php +++ b/src/Filesystem/JsonStreamFile.php @@ -18,10 +18,8 @@ /** * Wrapper around JSON files to read them in a stream. - * - * @final since 5.4 */ -class JsonStreamFile implements FileStreamInterface, WritableFileInterface +final class JsonStreamFile implements FileStreamInterface, WritableFileInterface { protected \SplFileObject $file; diff --git a/src/Filesystem/SplFile.php b/src/Filesystem/SplFile.php index 04c600f4..936f0ee2 100644 --- a/src/Filesystem/SplFile.php +++ b/src/Filesystem/SplFile.php @@ -15,10 +15,8 @@ /** * Wrapper around files to read/write them. - * - * @final since 5.4 */ -class SplFile +final class SplFile { protected \SplFileObject $file; @@ -76,12 +74,11 @@ public function isEndOfFile(): bool /** * Return an array containing current data and moving the file pointer. */ - public function readLine(?int $length = null): ?string + public function readLine(): ?string { if ($this->isEndOfFile()) { return null; } - $rawLine = $this->file->fgets(); // Fix issue on PHP 8 with empty line at the end, even if SKIP_EMPTY is set if ('' === $rawLine) { diff --git a/src/Filesystem/XmlFile.php b/src/Filesystem/XmlFile.php index fc109a0c..32c62987 100644 --- a/src/Filesystem/XmlFile.php +++ b/src/Filesystem/XmlFile.php @@ -18,10 +18,8 @@ /** * Read and write XML files. - * - * @final since 5.4 */ -class XmlFile +final class XmlFile { protected \SplFileObject $file; diff --git a/src/Logger/AbstractProcessor.php b/src/Logger/AbstractProcessor.php index 6be48ccc..c3849d2f 100644 --- a/src/Logger/AbstractProcessor.php +++ b/src/Logger/AbstractProcessor.php @@ -14,7 +14,7 @@ namespace CleverAge\ProcessBundle\Logger; use CleverAge\ProcessBundle\Configuration\TaskConfiguration; -use CleverAge\ProcessBundle\Manager\ProcessManager; +use CleverAge\ProcessBundle\Manager\ProcessManagerInterface; use CleverAge\ProcessBundle\Model\ProcessHistory; use Monolog\LogRecord; @@ -24,7 +24,7 @@ class AbstractProcessor { public function __construct( - protected ProcessManager $processManager, + protected ProcessManagerInterface $processManager, ) { } diff --git a/src/Manager/ProcessManager.php b/src/Manager/ProcessManager.php index 9afa6997..c5f3d933 100644 --- a/src/Manager/ProcessManager.php +++ b/src/Manager/ProcessManager.php @@ -35,19 +35,16 @@ use CleverAge\ProcessBundle\Model\ProcessState; use CleverAge\ProcessBundle\Model\ProcessStopCheckerInterface; use CleverAge\ProcessBundle\Model\TaskInterface; -use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; +use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistryInterface; use CleverAge\ProcessBundle\Registry\TaskRegistryInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockInterface; -use Symfony\Contracts\Service\ResetInterface; /** * Execute processes. - * - * @final since 5.4 */ -class ProcessManager implements ProcessManagerInterface, ResetInterface +final class ProcessManager implements ProcessManagerInterface { protected const int EXECUTE_PROCESS = 1; @@ -56,10 +53,10 @@ class ProcessManager implements ProcessManagerInterface, ResetInterface protected const int EXECUTE_FLUSH = 4; /** Prefix of the lock resource of an exclusive process, followed by its code */ - final public const string LOCK_PREFIX = 'cleverage_process.exclusive.'; + public const string LOCK_PREFIX = 'cleverage_process.exclusive.'; /** TTL of the lock of an exclusive process (seconds), refreshed before the tasks */ - final public const int LOCK_TTL = 300; + public const int LOCK_TTL = 300; /** * Indexed by task configuration (spl_object_id()): a sub-process may have a task with the same code. @@ -116,7 +113,7 @@ class ProcessManager implements ProcessManagerInterface, ResetInterface public function __construct( protected ProcessLogger $processLogger, protected TaskLogger $taskLogger, - protected ProcessConfigurationRegistry $processConfigurationRegistry, + protected ProcessConfigurationRegistryInterface $processConfigurationRegistry, protected ContextualOptionResolver $contextualOptionResolver, protected EventDispatcherInterface $eventDispatcher, protected TaskRegistryInterface $taskRegistry, diff --git a/src/Manager/ProcessManagerInterface.php b/src/Manager/ProcessManagerInterface.php index 234782a5..99d5b627 100644 --- a/src/Manager/ProcessManagerInterface.php +++ b/src/Manager/ProcessManagerInterface.php @@ -13,13 +13,16 @@ namespace CleverAge\ProcessBundle\Manager; +use CleverAge\ProcessBundle\Configuration\TaskConfiguration; use CleverAge\ProcessBundle\Exception\MissingProcessException; use CleverAge\ProcessBundle\Exception\ProcessFailedException; +use CleverAge\ProcessBundle\Model\ProcessHistory; +use Symfony\Contracts\Service\ResetInterface; /** * Executes processes (implemented by ProcessManager, autowired by this interface). */ -interface ProcessManagerInterface +interface ProcessManagerInterface extends ResetInterface { /** * Executes the process with the given input (given to its entry point) and context, returns the last output of its @@ -31,4 +34,14 @@ interface ProcessManagerInterface * @throws ProcessFailedException when a task fails with the "stop" error strategy */ public function execute(string $processCode, mixed $input = null, array $context = []): mixed; + + /** + * The history of the process being executed (null outside an execution), added to the log records. + */ + public function getProcessHistory(): ?ProcessHistory; + + /** + * The configuration of the task being executed (null outside an execution), added to the log records. + */ + public function getTaskConfiguration(): ?TaskConfiguration; } diff --git a/src/Model/ProcessHistory.php b/src/Model/ProcessHistory.php index e7afa12e..208e139a 100644 --- a/src/Model/ProcessHistory.php +++ b/src/Model/ProcessHistory.php @@ -17,18 +17,16 @@ /** * Logs information about a process. - * - * @final since 5.4 */ -class ProcessHistory implements \Stringable +final class ProcessHistory implements \Stringable { - final public const string STATE_STARTED = 'started'; + public const string STATE_STARTED = 'started'; - final public const string STATE_SUCCESS = 'success'; + public const string STATE_SUCCESS = 'success'; - final public const string STATE_FAILED = 'failed'; + public const string STATE_FAILED = 'failed'; - final public const string STATE_STOPPED = 'stopped'; + public const string STATE_STOPPED = 'stopped'; protected float $id; diff --git a/src/Model/ProcessState.php b/src/Model/ProcessState.php index 24e0262e..a0bde514 100644 --- a/src/Model/ProcessState.php +++ b/src/Model/ProcessState.php @@ -21,25 +21,23 @@ /** * Used to pass information between tasks. - * - * @final since 5.4 */ -class ProcessState +final class ProcessState { - final public const array STATUS = [ + public const array STATUS = [ self::STATUS_NEW, self::STATUS_PENDING, self::STATUS_PROCESSING, self::STATUS_RESOLVED, ]; - final public const string STATUS_NEW = 'new'; + public const string STATUS_NEW = 'new'; - final public const string STATUS_PENDING = 'pending'; + public const string STATUS_PENDING = 'pending'; - final public const string STATUS_PROCESSING = 'processing'; + public const string STATUS_PROCESSING = 'processing'; - final public const string STATUS_RESOLVED = 'resolved'; + public const string STATUS_RESOLVED = 'resolved'; protected TaskConfiguration $taskConfiguration; diff --git a/src/Model/SubprocessInstance.php b/src/Model/SubprocessInstance.php index 6d94bd52..ebe1c065 100644 --- a/src/Model/SubprocessInstance.php +++ b/src/Model/SubprocessInstance.php @@ -20,12 +20,9 @@ use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; -/** - * @final since 5.4 - */ -class SubprocessInstance +final class SubprocessInstance { - final public const string OPTION_JSON_BUFFERING = 'json-buffering'; + public const string OPTION_JSON_BUFFERING = 'json-buffering'; protected Process $process; diff --git a/src/Registry/ProcessConfigurationRegistry.php b/src/Registry/ProcessConfigurationRegistry.php index 25814193..318a0d66 100644 --- a/src/Registry/ProcessConfigurationRegistry.php +++ b/src/Registry/ProcessConfigurationRegistry.php @@ -23,10 +23,8 @@ /** * Build and holds all the process configurations. - * - * @final since 5.4 */ -class ProcessConfigurationRegistry implements ProcessConfigurationRegistryInterface +final class ProcessConfigurationRegistry implements ProcessConfigurationRegistryInterface { /** * @var array diff --git a/src/Registry/ProcessConfigurationRegistryInterface.php b/src/Registry/ProcessConfigurationRegistryInterface.php index 42d4a638..9b7925fd 100644 --- a/src/Registry/ProcessConfigurationRegistryInterface.php +++ b/src/Registry/ProcessConfigurationRegistryInterface.php @@ -16,11 +16,12 @@ use CleverAge\ProcessBundle\Configuration\ProcessConfiguration; use CleverAge\ProcessBundle\Exception\InvalidProcessConfigurationException; use CleverAge\ProcessBundle\Exception\MissingProcessException; +use Symfony\Contracts\Service\ResetInterface; /** * Gives the process configurations (implemented by ProcessConfigurationRegistry, autowired by this interface). */ -interface ProcessConfigurationRegistryInterface +interface ProcessConfigurationRegistryInterface extends ResetInterface { /** * @throws MissingProcessException when the process does not exist @@ -37,4 +38,11 @@ public function getProcessConfiguration(string $processCode): ProcessConfigurati public function getProcessConfigurations(): array; public function hasProcessConfiguration(string $processCode): bool; + + /** + * The codes of the processes, without resolving their configuration. + * + * @return list + */ + public function getProcessCodes(): array; } diff --git a/src/Registry/TransformerRegistry.php b/src/Registry/TransformerRegistry.php index 6ee9bf81..b57cff86 100644 --- a/src/Registry/TransformerRegistry.php +++ b/src/Registry/TransformerRegistry.php @@ -24,10 +24,8 @@ * The transformer services are fetched lazily from a service locator indexed by code (`code` attribute of the * `cleverage.transformer` tag, or `#[AsTransformer]`, see TransformerLocatorCompilerPass): a transformer is only * instantiated when it is used. - * - * @final since 5.4 */ -class TransformerRegistry implements TransformerRegistryInterface +final class TransformerRegistry implements TransformerRegistryInterface { /** * Transformers already fetched from the locator. diff --git a/src/Task/AggregateIterableTask.php b/src/Task/AggregateIterableTask.php index cf67d36d..805e3aeb 100644 --- a/src/Task/AggregateIterableTask.php +++ b/src/Task/AggregateIterableTask.php @@ -20,10 +20,8 @@ * Class AggregateIterableTask. * * Aggregate the result of iterable tasks in an array - * - * @final since 5.4 */ -class AggregateIterableTask implements BlockingTaskInterface +final class AggregateIterableTask implements BlockingTaskInterface { /** * @var list diff --git a/src/Task/ArrayMergeTask.php b/src/Task/ArrayMergeTask.php index ac821d7d..04822286 100644 --- a/src/Task/ArrayMergeTask.php +++ b/src/Task/ArrayMergeTask.php @@ -22,10 +22,8 @@ /** * Merge every input array, and return the result. - * - * @final since 5.4 */ -class ArrayMergeTask extends AbstractConfigurableTask implements BlockingTaskInterface +final class ArrayMergeTask extends AbstractConfigurableTask implements BlockingTaskInterface { protected const array MERGE_FUNC = ['array_merge', 'array_merge_recursive', 'array_replace', 'array_replace_recursive']; diff --git a/src/Task/ColumnAggregatorTask.php b/src/Task/ColumnAggregatorTask.php index c0ee62ae..f9fcb6b1 100644 --- a/src/Task/ColumnAggregatorTask.php +++ b/src/Task/ColumnAggregatorTask.php @@ -25,10 +25,8 @@ /** * For each configured column, collect the input rows that contain this column (and match the optional condition), and * output all the groups once all previous tasks are resolved. - * - * @final since 5.4 */ -class ColumnAggregatorTask extends AbstractConfigurableTask implements BlockingTaskInterface +final class ColumnAggregatorTask extends AbstractConfigurableTask implements BlockingTaskInterface { use ConditionTrait; diff --git a/src/Task/ConstantIterableOutputTask.php b/src/Task/ConstantIterableOutputTask.php index 5ba589b9..fa1e147c 100644 --- a/src/Task/ConstantIterableOutputTask.php +++ b/src/Task/ConstantIterableOutputTask.php @@ -18,10 +18,8 @@ /** * Always send the same output regardless of the input, only accepts array for values and iterate over it. - * - * @final since 5.4 */ -class ConstantIterableOutputTask extends AbstractIterableOutputTask +final class ConstantIterableOutputTask extends AbstractIterableOutputTask { protected function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Task/ConstantOutputTask.php b/src/Task/ConstantOutputTask.php index 9a820a2a..67fd6b52 100644 --- a/src/Task/ConstantOutputTask.php +++ b/src/Task/ConstantOutputTask.php @@ -19,10 +19,8 @@ /** * Always send the same output regardless of the input. - * - * @final since 5.4 */ -class ConstantOutputTask extends AbstractConfigurableTask +final class ConstantOutputTask extends AbstractConfigurableTask { public function execute(ProcessState $state): void { diff --git a/src/Task/CounterTask.php b/src/Task/CounterTask.php index aa6979ba..4e0c8976 100644 --- a/src/Task/CounterTask.php +++ b/src/Task/CounterTask.php @@ -23,10 +23,8 @@ /** * Count the number of times the task is processed and continue every N iteration (skip the rest of the time) * Flush at the end with the actual count. - * - * @final since 5.4 */ -class CounterTask extends AbstractConfigurableTask implements FlushableTaskInterface +final class CounterTask extends AbstractConfigurableTask implements FlushableTaskInterface { protected int $counter = 0; diff --git a/src/Task/Debug/DebugTask.php b/src/Task/Debug/DebugTask.php index 9c71e678..138f73e3 100644 --- a/src/Task/Debug/DebugTask.php +++ b/src/Task/Debug/DebugTask.php @@ -19,10 +19,8 @@ /** * Dump the content of the input. - * - * @final since 5.4 */ -class DebugTask implements TaskInterface +final class DebugTask implements TaskInterface { public function execute(ProcessState $state): void { diff --git a/src/Task/Debug/DieTask.php b/src/Task/Debug/DieTask.php index 6b346c69..642ecf7b 100644 --- a/src/Task/Debug/DieTask.php +++ b/src/Task/Debug/DieTask.php @@ -20,10 +20,8 @@ * Class DieTask. * * Stops the process brutally - * - * @final since 5.4 */ -class DieTask implements TaskInterface +final class DieTask implements TaskInterface { public function execute(ProcessState $state): never { diff --git a/src/Task/Debug/ErrorForwarderTask.php b/src/Task/Debug/ErrorForwarderTask.php index 9d2684d3..d341de95 100644 --- a/src/Task/Debug/ErrorForwarderTask.php +++ b/src/Task/Debug/ErrorForwarderTask.php @@ -19,10 +19,8 @@ /** * This is a dummy task mostly intended for testing purpose. * Forward any input to the error output. - * - * @final since 5.4 */ -class ErrorForwarderTask implements TaskInterface +final class ErrorForwarderTask implements TaskInterface { public function execute(ProcessState $state): void { diff --git a/src/Task/Debug/StopwatchTask.php b/src/Task/Debug/StopwatchTask.php index eb972e93..5659b59a 100644 --- a/src/Task/Debug/StopwatchTask.php +++ b/src/Task/Debug/StopwatchTask.php @@ -20,10 +20,8 @@ /** * Log all the __root__ events of the Stopwatch component. - * - * @final since 5.4 */ -class StopwatchTask implements TaskInterface +final class StopwatchTask implements TaskInterface { public function __construct( protected LoggerInterface $logger, diff --git a/src/Task/DummyTask.php b/src/Task/DummyTask.php index dda70f59..77427d07 100644 --- a/src/Task/DummyTask.php +++ b/src/Task/DummyTask.php @@ -18,10 +18,8 @@ /** * Dummy task that pass the input to the output. - * - * @final since 5.4 */ -class DummyTask implements TaskInterface +final class DummyTask implements TaskInterface { public function execute(ProcessState $state): void { diff --git a/src/Task/Event/EventDispatcherTask.php b/src/Task/Event/EventDispatcherTask.php index 5b1acb4f..30428272 100644 --- a/src/Task/Event/EventDispatcherTask.php +++ b/src/Task/Event/EventDispatcherTask.php @@ -22,10 +22,8 @@ /** * Call the Symfony event dispatcher * If defined as passive (which is the default), it automatically set the output from the input. - * - * @final since 5.4 */ -class EventDispatcherTask extends AbstractConfigurableTask +final class EventDispatcherTask extends AbstractConfigurableTask { public function __construct( protected EventDispatcherInterface $eventDispatcher, diff --git a/src/Task/File/Csv/CsvSplitterTask.php b/src/Task/File/Csv/CsvSplitterTask.php index d6c22cf5..43e13236 100644 --- a/src/Task/File/Csv/CsvSplitterTask.php +++ b/src/Task/File/Csv/CsvSplitterTask.php @@ -22,10 +22,8 @@ /** * Split long CSV files into smaller ones, keeping the headers. - * - * @final since 5.4 */ -class CsvSplitterTask extends InputCsvReaderTask +final class CsvSplitterTask extends InputCsvReaderTask { /** * Number of data lines written in the last produced file. diff --git a/src/Task/File/Csv/CsvWriterTask.php b/src/Task/File/Csv/CsvWriterTask.php index 15646bee..8cbd02b6 100644 --- a/src/Task/File/Csv/CsvWriterTask.php +++ b/src/Task/File/Csv/CsvWriterTask.php @@ -25,10 +25,8 @@ * Ignores any input. * * @property CsvFile $csv - * - * @final since 5.4 */ -class CsvWriterTask extends AbstractCsvTask implements BlockingTaskInterface +final class CsvWriterTask extends AbstractCsvTask implements BlockingTaskInterface { /** * First characters of a value interpreted as a formula by a spreadsheet application (as the CsvEncoder of the @@ -127,9 +125,9 @@ private function escapeFormula(mixed $value): mixed /** * @param array $options * - * @return list|null + * @return list */ - protected function getHeaders(ProcessState $state, array $options): ?array + protected function getHeaders(ProcessState $state, array $options): array { $headers = $options['headers']; if (null === $headers) { diff --git a/src/Task/File/FileMoverTask.php b/src/Task/File/FileMoverTask.php index 2969b30a..91602d76 100644 --- a/src/Task/File/FileMoverTask.php +++ b/src/Task/File/FileMoverTask.php @@ -21,10 +21,8 @@ /** * Move the file passed as input, requires the destination path in options. - * - * @final since 5.4 */ -class FileMoverTask extends AbstractConfigurableTask +final class FileMoverTask extends AbstractConfigurableTask { public function execute(ProcessState $state): void { diff --git a/src/Task/File/FileRemoverTask.php b/src/Task/File/FileRemoverTask.php index 298b8f23..a6411110 100644 --- a/src/Task/File/FileRemoverTask.php +++ b/src/Task/File/FileRemoverTask.php @@ -19,10 +19,8 @@ /** * Simply delete the file passed as input. - * - * @final since 5.4 */ -class FileRemoverTask implements TaskInterface +final class FileRemoverTask implements TaskInterface { public function execute(ProcessState $state): void { diff --git a/src/Task/File/FileSplitterTask.php b/src/Task/File/FileSplitterTask.php index f0cb6c1c..6efbf5da 100644 --- a/src/Task/File/FileSplitterTask.php +++ b/src/Task/File/FileSplitterTask.php @@ -22,10 +22,8 @@ /** * Split long file into smaller ones. - * - * @final since 5.4 */ -class FileSplitterTask extends AbstractConfigurableTask implements IterableTaskInterface +final class FileSplitterTask extends AbstractConfigurableTask implements IterableTaskInterface { protected ?SplFile $file = null; diff --git a/src/Task/File/FileWriterTask.php b/src/Task/File/FileWriterTask.php index 2ae1351c..ea039838 100644 --- a/src/Task/File/FileWriterTask.php +++ b/src/Task/File/FileWriterTask.php @@ -18,10 +18,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class FileWriterTask extends AbstractConfigurableTask +final class FileWriterTask extends AbstractConfigurableTask { public function execute(ProcessState $state): void { diff --git a/src/Task/File/InputFileReaderTask.php b/src/Task/File/InputFileReaderTask.php index a29194c8..9ef9623a 100644 --- a/src/Task/File/InputFileReaderTask.php +++ b/src/Task/File/InputFileReaderTask.php @@ -19,10 +19,8 @@ /** * Reads the whole input file and outputs its content. - * - * @final since 5.4 */ -class InputFileReaderTask extends FileReaderTask +final class InputFileReaderTask extends FileReaderTask { #[\Override] public function initialize(ProcessState $state): void diff --git a/src/Task/File/InputFolderBrowserTask.php b/src/Task/File/InputFolderBrowserTask.php index a50d169b..24245e2b 100644 --- a/src/Task/File/InputFolderBrowserTask.php +++ b/src/Task/File/InputFolderBrowserTask.php @@ -22,10 +22,8 @@ /** * Browse a folder with the path as an input and iterate each file for output. - * - * @final since 5.4 */ -class InputFolderBrowserTask extends FolderBrowserTask implements FlushableTaskInterface +final class InputFolderBrowserTask extends FolderBrowserTask implements FlushableTaskInterface { protected ?string $folderPath = null; diff --git a/src/Task/File/InputLineReaderTask.php b/src/Task/File/InputLineReaderTask.php index c1f59ab7..7570b0f9 100644 --- a/src/Task/File/InputLineReaderTask.php +++ b/src/Task/File/InputLineReaderTask.php @@ -18,10 +18,8 @@ /** * Reads an input file line by line and outputs each line. - * - * @final since 5.4 */ -class InputLineReaderTask extends LineReaderTask +final class InputLineReaderTask extends LineReaderTask { /** * @return array diff --git a/src/Task/File/JsonStream/JsonStreamReaderTask.php b/src/Task/File/JsonStream/JsonStreamReaderTask.php index bbde165f..133d045b 100644 --- a/src/Task/File/JsonStream/JsonStreamReaderTask.php +++ b/src/Task/File/JsonStream/JsonStreamReaderTask.php @@ -19,10 +19,7 @@ use CleverAge\ProcessBundle\Model\ProcessState; use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class JsonStreamReaderTask extends AbstractConfigurableTask implements IterableTaskInterface +final class JsonStreamReaderTask extends AbstractConfigurableTask implements IterableTaskInterface { protected ?JsonStreamFile $file = null; diff --git a/src/Task/File/JsonStream/JsonStreamWriterTask.php b/src/Task/File/JsonStream/JsonStreamWriterTask.php index d3b436cb..f156686d 100644 --- a/src/Task/File/JsonStream/JsonStreamWriterTask.php +++ b/src/Task/File/JsonStream/JsonStreamWriterTask.php @@ -22,10 +22,7 @@ use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class JsonStreamWriterTask extends AbstractConfigurableTask implements BlockingTaskInterface, FinalizableTaskInterface +final class JsonStreamWriterTask extends AbstractConfigurableTask implements BlockingTaskInterface, FinalizableTaskInterface { protected ?JsonStreamFile $file = null; diff --git a/src/Task/File/Xml/XmlReaderTask.php b/src/Task/File/Xml/XmlReaderTask.php index 0878b6b2..0835c57c 100644 --- a/src/Task/File/Xml/XmlReaderTask.php +++ b/src/Task/File/Xml/XmlReaderTask.php @@ -21,10 +21,8 @@ /** * Read an XML file. - * - * @final since 5.4 */ -class XmlReaderTask extends AbstractConfigurableTask +final class XmlReaderTask extends AbstractConfigurableTask { public function __construct( protected LoggerInterface $logger, diff --git a/src/Task/File/Xml/XmlStreamReaderTask.php b/src/Task/File/Xml/XmlStreamReaderTask.php index 4c19adb4..654c9ab2 100644 --- a/src/Task/File/Xml/XmlStreamReaderTask.php +++ b/src/Task/File/Xml/XmlStreamReaderTask.php @@ -24,10 +24,8 @@ /** * Read an XML file element by element with \XMLReader, so that the whole file is never loaded in memory. - * - * @final since 5.4 */ -class XmlStreamReaderTask extends AbstractConfigurableTask implements IterableTaskInterface, FinalizableTaskInterface +final class XmlStreamReaderTask extends AbstractConfigurableTask implements IterableTaskInterface, FinalizableTaskInterface { protected ?\XMLReader $reader = null; diff --git a/src/Task/File/Xml/XmlWriterTask.php b/src/Task/File/Xml/XmlWriterTask.php index f9ecb724..36d8292a 100644 --- a/src/Task/File/Xml/XmlWriterTask.php +++ b/src/Task/File/Xml/XmlWriterTask.php @@ -22,10 +22,8 @@ /** * Write an XML file. - * - * @final since 5.4 */ -class XmlWriterTask extends AbstractConfigurableTask +final class XmlWriterTask extends AbstractConfigurableTask { public function __construct( protected LoggerInterface $logger, diff --git a/src/Task/File/Yaml/YamlReaderTask.php b/src/Task/File/Yaml/YamlReaderTask.php index 2d20fa7b..71d36357 100644 --- a/src/Task/File/Yaml/YamlReaderTask.php +++ b/src/Task/File/Yaml/YamlReaderTask.php @@ -23,10 +23,8 @@ /** * Reads a YAML file and iterate over its root elements. - * - * @final since 5.4 */ -class YamlReaderTask extends AbstractIterableOutputTask +final class YamlReaderTask extends AbstractIterableOutputTask { protected function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Task/File/Yaml/YamlWriterTask.php b/src/Task/File/Yaml/YamlWriterTask.php index ba87cdb4..514e939d 100644 --- a/src/Task/File/Yaml/YamlWriterTask.php +++ b/src/Task/File/Yaml/YamlWriterTask.php @@ -21,10 +21,8 @@ /** * Writes a YAML file from an array. - * - * @final since 5.4 */ -class YamlWriterTask extends AbstractConfigurableTask +final class YamlWriterTask extends AbstractConfigurableTask { public function execute(ProcessState $state): void { diff --git a/src/Task/FilterTask.php b/src/Task/FilterTask.php index ac7f2c9c..064cc167 100644 --- a/src/Task/FilterTask.php +++ b/src/Task/FilterTask.php @@ -23,10 +23,8 @@ * Skip inputs under given matching conditions * - equality is strictly checked * - unexisting key is the same as null. - * - * @final since 5.4 */ -class FilterTask extends AbstractConfigurableTask +final class FilterTask extends AbstractConfigurableTask { use ConditionTrait; diff --git a/src/Task/GroupByAggregateIterableTask.php b/src/Task/GroupByAggregateIterableTask.php index fadab599..98751302 100644 --- a/src/Task/GroupByAggregateIterableTask.php +++ b/src/Task/GroupByAggregateIterableTask.php @@ -22,12 +22,10 @@ /** * Attempt to aggregate inputs in an associative array with a key formed by configurable fields of the input. * This task could be used to remove duplicates from the aggregate. - * - * @final since 5.4 */ -class GroupByAggregateIterableTask extends AbstractConfigurableTask implements BlockingTaskInterface +final class GroupByAggregateIterableTask extends AbstractConfigurableTask implements BlockingTaskInterface { - final public const string GROUP_BY_OPTION = 'group_by_accessors'; + public const string GROUP_BY_OPTION = 'group_by_accessors'; /** * @var array diff --git a/src/Task/InputAggregatorTask.php b/src/Task/InputAggregatorTask.php index c417e779..9b8a1efe 100644 --- a/src/Task/InputAggregatorTask.php +++ b/src/Task/InputAggregatorTask.php @@ -26,10 +26,8 @@ * The inputs of an item are told apart by the executions of their common ancestors: when a branch skips an item, the * inputs already received for this item are dropped when the inputs of the next item arrive, instead of being joined * with them. - * - * @final since 5.4 */ -class InputAggregatorTask extends AbstractConfigurableTask +final class InputAggregatorTask extends AbstractConfigurableTask { /** * @var array diff --git a/src/Task/InputIteratorTask.php b/src/Task/InputIteratorTask.php index b255bbc9..9a6e955d 100644 --- a/src/Task/InputIteratorTask.php +++ b/src/Task/InputIteratorTask.php @@ -18,10 +18,8 @@ /** * Iterates from the input of the previous task. - * - * @final since 5.4 */ -class InputIteratorTask extends AbstractIterableOutputTask +final class InputIteratorTask extends AbstractIterableOutputTask { protected function initializeIterator(ProcessState $state): \Iterator { diff --git a/src/Task/IterableBatchTask.php b/src/Task/IterableBatchTask.php index 457d8525..394ef1c8 100644 --- a/src/Task/IterableBatchTask.php +++ b/src/Task/IterableBatchTask.php @@ -22,11 +22,9 @@ /** * A Batch task that iterate on flush - * It's mainly an example task since it's not useful as-is, but the processInput method may allow custom overrides. - * - * @final since 5.4 + * It's mainly an example task since it's not useful as-is. */ -class IterableBatchTask extends AbstractConfigurableTask implements FlushableTaskInterface, IterableTaskInterface +final class IterableBatchTask extends AbstractConfigurableTask implements FlushableTaskInterface, IterableTaskInterface { /** * @var \SplQueue|null diff --git a/src/Task/ObjectUpdaterTask.php b/src/Task/ObjectUpdaterTask.php index 89632065..0a43f8ca 100644 --- a/src/Task/ObjectUpdaterTask.php +++ b/src/Task/ObjectUpdaterTask.php @@ -22,10 +22,8 @@ /** * Takes an array containing an object and a value updates an object's property with this value, then return the object. - * - * @final since 5.4 */ -class ObjectUpdaterTask extends AbstractConfigurableTask +final class ObjectUpdaterTask extends AbstractConfigurableTask { public function __construct( protected PropertyAccessorInterface $accessor, diff --git a/src/Task/Process/CommandRunnerTask.php b/src/Task/Process/CommandRunnerTask.php index 185b0c3b..0eb66346 100644 --- a/src/Task/Process/CommandRunnerTask.php +++ b/src/Task/Process/CommandRunnerTask.php @@ -20,10 +20,8 @@ /** * Launch a system command for each input, passing input to command. - * - * @final since 5.4 */ -class CommandRunnerTask extends AbstractConfigurableTask +final class CommandRunnerTask extends AbstractConfigurableTask { /** * @param string $projectDir default working directory of the commands diff --git a/src/Task/Process/ProcessExecutorTask.php b/src/Task/Process/ProcessExecutorTask.php index f9531ab3..aff99932 100644 --- a/src/Task/Process/ProcessExecutorTask.php +++ b/src/Task/Process/ProcessExecutorTask.php @@ -13,10 +13,10 @@ namespace CleverAge\ProcessBundle\Task\Process; -use CleverAge\ProcessBundle\Manager\ProcessManager; +use CleverAge\ProcessBundle\Manager\ProcessManagerInterface; use CleverAge\ProcessBundle\Model\AbstractConfigurableTask; use CleverAge\ProcessBundle\Model\ProcessState; -use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; +use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistryInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\OptionsResolver\Options; @@ -25,16 +25,14 @@ /** * Execute a process for each input: the input is passed to the process entry point, and the output of its end point * becomes the task output. - * - * @final since 5.4 */ -class ProcessExecutorTask extends AbstractConfigurableTask +final class ProcessExecutorTask extends AbstractConfigurableTask { protected ?string $process = null; public function __construct( - protected ProcessManager $processManager, - protected ProcessConfigurationRegistry $processRegistry, + protected ProcessManagerInterface $processManager, + protected ProcessConfigurationRegistryInterface $processRegistry, protected LoggerInterface $logger, ) { } diff --git a/src/Task/Process/ProcessLauncherTask.php b/src/Task/Process/ProcessLauncherTask.php index d3fea153..09b73236 100644 --- a/src/Task/Process/ProcessLauncherTask.php +++ b/src/Task/Process/ProcessLauncherTask.php @@ -20,7 +20,7 @@ use CleverAge\ProcessBundle\Model\IterableTaskInterface; use CleverAge\ProcessBundle\Model\ProcessState; use CleverAge\ProcessBundle\Model\SubprocessInstance; -use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; +use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistryInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Filesystem\Filesystem; @@ -29,10 +29,8 @@ /** * Launch a new process for each input received, input must be a scalar, a resource or a \Traversable. - * - * @final since 5.4 */ -class ProcessLauncherTask extends AbstractConfigurableTask implements FlushableTaskInterface, IterableTaskInterface, FinalizableTaskInterface +final class ProcessLauncherTask extends AbstractConfigurableTask implements FlushableTaskInterface, IterableTaskInterface, FinalizableTaskInterface { /** Seconds given to the sub-processes to stop after SIGTERM, before SIGKILL */ protected const int STOP_TIMEOUT = 5; @@ -58,7 +56,7 @@ class ProcessLauncherTask extends AbstractConfigurableTask implements FlushableT */ public function __construct( protected LoggerInterface $logger, - protected ProcessConfigurationRegistry $processRegistry, + protected ProcessConfigurationRegistryInterface $processRegistry, protected string $consolePath, protected ?string $environment = null, ) { diff --git a/src/Task/PropertyGetterTask.php b/src/Task/PropertyGetterTask.php index 8e3352a4..8b2882db 100644 --- a/src/Task/PropertyGetterTask.php +++ b/src/Task/PropertyGetterTask.php @@ -21,10 +21,8 @@ /** * Get a property on the input and return it with PropertyAccessor. - * - * @final since 5.4 */ -class PropertyGetterTask extends AbstractConfigurableTask +final class PropertyGetterTask extends AbstractConfigurableTask { public function __construct( protected LoggerInterface $logger, diff --git a/src/Task/PropertySetterTask.php b/src/Task/PropertySetterTask.php index ed5088d9..b71718af 100644 --- a/src/Task/PropertySetterTask.php +++ b/src/Task/PropertySetterTask.php @@ -21,10 +21,8 @@ /** * Accepts an object or an array as input and sets values from configuration. - * - * @final since 5.4 */ -class PropertySetterTask extends AbstractConfigurableTask +final class PropertySetterTask extends AbstractConfigurableTask { public function __construct( protected LoggerInterface $logger, diff --git a/src/Task/Reporting/AdvancedStatCounterTask.php b/src/Task/Reporting/AdvancedStatCounterTask.php index 5e8018e1..d6a7eed3 100644 --- a/src/Task/Reporting/AdvancedStatCounterTask.php +++ b/src/Task/Reporting/AdvancedStatCounterTask.php @@ -20,10 +20,8 @@ /** * Count the time between 2 iterations, and log statistics every N executions. The input is passed to the output. - * - * @final since 5.4 */ -class AdvancedStatCounterTask extends AbstractConfigurableTask +final class AdvancedStatCounterTask extends AbstractConfigurableTask { protected ?\DateTime $startedAt = null; diff --git a/src/Task/Reporting/LoggerTask.php b/src/Task/Reporting/LoggerTask.php index 79e53dc4..2b8325d9 100644 --- a/src/Task/Reporting/LoggerTask.php +++ b/src/Task/Reporting/LoggerTask.php @@ -23,10 +23,8 @@ * Class LoggerTask. * * Add custom log in state - * - * @final since 5.4 */ -class LoggerTask extends AbstractConfigurableTask +final class LoggerTask extends AbstractConfigurableTask { public function __construct( protected LoggerInterface $logger, diff --git a/src/Task/Reporting/StatCounterTask.php b/src/Task/Reporting/StatCounterTask.php index 116f6632..a00b78d3 100644 --- a/src/Task/Reporting/StatCounterTask.php +++ b/src/Task/Reporting/StatCounterTask.php @@ -19,10 +19,8 @@ /** * Count the number of times the task was executed, and log it when the process ends. The input is passed to the output. - * - * @final since 5.4 */ -class StatCounterTask implements FinalizableTaskInterface +final class StatCounterTask implements FinalizableTaskInterface { protected int $counter = 0; diff --git a/src/Task/RowAggregatorTask.php b/src/Task/RowAggregatorTask.php index 9989f841..bcccef8a 100644 --- a/src/Task/RowAggregatorTask.php +++ b/src/Task/RowAggregatorTask.php @@ -24,10 +24,8 @@ * Group input rows sharing the same value for the "aggregate_by" column. Each group is made of the first received row * (without the "aggregate_columns"), plus a sub-array under "aggregation_key" listing the "aggregate_columns" values of * every row of the group. The groups are output once all previous tasks are resolved. - * - * @final since 5.4 */ -class RowAggregatorTask extends AbstractConfigurableTask implements BlockingTaskInterface +final class RowAggregatorTask extends AbstractConfigurableTask implements BlockingTaskInterface { /** * @var array diff --git a/src/Task/Serialization/DenormalizerTask.php b/src/Task/Serialization/DenormalizerTask.php index 8b18ad76..b5c7e4e1 100644 --- a/src/Task/Serialization/DenormalizerTask.php +++ b/src/Task/Serialization/DenormalizerTask.php @@ -20,10 +20,8 @@ /** * Denormalize input to output with configurable class and format. - * - * @final since 5.4 */ -class DenormalizerTask extends AbstractConfigurableTask +final class DenormalizerTask extends AbstractConfigurableTask { public function __construct( protected DenormalizerInterface $denormalizer, diff --git a/src/Task/Serialization/DeserializerTask.php b/src/Task/Serialization/DeserializerTask.php index 1d4b70ee..3567af88 100644 --- a/src/Task/Serialization/DeserializerTask.php +++ b/src/Task/Serialization/DeserializerTask.php @@ -18,10 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\SerializerInterface; -/** - * @final since 5.4 - */ -class DeserializerTask extends AbstractConfigurableTask +final class DeserializerTask extends AbstractConfigurableTask { public function __construct( protected SerializerInterface $serializer, diff --git a/src/Task/Serialization/NormalizerTask.php b/src/Task/Serialization/NormalizerTask.php index 23f8ee14..4a84cf37 100644 --- a/src/Task/Serialization/NormalizerTask.php +++ b/src/Task/Serialization/NormalizerTask.php @@ -21,10 +21,8 @@ /** * Normalize input to output with configurable format. - * - * @final since 5.4 */ -class NormalizerTask extends AbstractConfigurableTask +final class NormalizerTask extends AbstractConfigurableTask { public function __construct( protected NormalizerInterface $normalizer, diff --git a/src/Task/Serialization/SerializerTask.php b/src/Task/Serialization/SerializerTask.php index 8293feda..dc4e948e 100644 --- a/src/Task/Serialization/SerializerTask.php +++ b/src/Task/Serialization/SerializerTask.php @@ -18,10 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\SerializerInterface; -/** - * @final since 5.4 - */ -class SerializerTask extends AbstractConfigurableTask +final class SerializerTask extends AbstractConfigurableTask { public function __construct( protected SerializerInterface $serializer, diff --git a/src/Task/SimpleBatchTask.php b/src/Task/SimpleBatchTask.php index b5245cf6..bd099213 100644 --- a/src/Task/SimpleBatchTask.php +++ b/src/Task/SimpleBatchTask.php @@ -20,10 +20,8 @@ /** * Simple example of how to manage an internal buffer for batch processing. - * - * @final since 5.4 */ -class SimpleBatchTask extends AbstractConfigurableTask implements FlushableTaskInterface +final class SimpleBatchTask extends AbstractConfigurableTask implements FlushableTaskInterface { /** * @var list diff --git a/src/Task/SkipEmptyTask.php b/src/Task/SkipEmptyTask.php index dc1c0892..a27cdf39 100644 --- a/src/Task/SkipEmptyTask.php +++ b/src/Task/SkipEmptyTask.php @@ -19,10 +19,8 @@ /** * Allow to skip the execution on empty input. * Useful when combined with an aggregator task. - * - * @final since 5.4 */ -class SkipEmptyTask implements TaskInterface +final class SkipEmptyTask implements TaskInterface { public function execute(ProcessState $state): void { diff --git a/src/Task/SplitJoinLineTask.php b/src/Task/SplitJoinLineTask.php index a1019163..27d16e93 100644 --- a/src/Task/SplitJoinLineTask.php +++ b/src/Task/SplitJoinLineTask.php @@ -19,10 +19,8 @@ /** * Split a single line into multiple lines based on multiple columns and split characters. - * - * @final since 5.4 */ -class SplitJoinLineTask extends AbstractIterableOutputTask +final class SplitJoinLineTask extends AbstractIterableOutputTask { #[\Override] public function next(ProcessState $state): bool diff --git a/src/Task/StopTask.php b/src/Task/StopTask.php index cad6fef0..8dffe3af 100644 --- a/src/Task/StopTask.php +++ b/src/Task/StopTask.php @@ -18,10 +18,8 @@ /** * Allows to directly stop a process on purpose, marking it as stopped: it is not a failure. - * - * @final since 5.4 */ -class StopTask implements TaskInterface +final class StopTask implements TaskInterface { public function execute(ProcessState $state): void { diff --git a/src/Task/TransformerTask.php b/src/Task/TransformerTask.php index ef61f821..614b649c 100644 --- a/src/Task/TransformerTask.php +++ b/src/Task/TransformerTask.php @@ -16,7 +16,7 @@ use CleverAge\ProcessBundle\Exception\TransformerException; use CleverAge\ProcessBundle\Model\AbstractConfigurableTask; use CleverAge\ProcessBundle\Model\ProcessState; -use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use CleverAge\ProcessBundle\Transformer\TransformerInterface; use CleverAge\ProcessBundle\Transformer\TransformerTrait; use Psr\Log\LoggerInterface; @@ -24,10 +24,8 @@ /** * Transform an array of data based on mapping and sub-transformers. - * - * @final since 5.4 */ -class TransformerTask extends AbstractConfigurableTask +final class TransformerTask extends AbstractConfigurableTask { use TransformerTrait; @@ -35,7 +33,7 @@ class TransformerTask extends AbstractConfigurableTask public function __construct( protected LoggerInterface $logger, - TransformerRegistry $transformerRegistry, + TransformerRegistryInterface $transformerRegistry, ) { $this->transformerRegistry = $transformerRegistry; } diff --git a/src/Task/Validation/ValidatorTask.php b/src/Task/Validation/ValidatorTask.php index 1985a891..8441e4bf 100644 --- a/src/Task/Validation/ValidatorTask.php +++ b/src/Task/Validation/ValidatorTask.php @@ -26,10 +26,8 @@ /** * Validate the input and pass it to the output. - * - * @final since 5.4 */ -class ValidatorTask extends AbstractConfigurableTask +final class ValidatorTask extends AbstractConfigurableTask { public function __construct( protected LoggerInterface $logger, diff --git a/src/Transformer/Array/ArrayElementTransformer.php b/src/Transformer/Array/ArrayElementTransformer.php index b480f983..59062bca 100644 --- a/src/Transformer/Array/ArrayElementTransformer.php +++ b/src/Transformer/Array/ArrayElementTransformer.php @@ -18,10 +18,8 @@ /** * Return the nth element of an array. - * - * @final since 5.4 */ -class ArrayElementTransformer implements ConfigurableTransformerInterface +final class ArrayElementTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/Array/ArrayFilterTransformer.php b/src/Transformer/Array/ArrayFilterTransformer.php index 85d38c76..500e6bca 100644 --- a/src/Transformer/Array/ArrayFilterTransformer.php +++ b/src/Transformer/Array/ArrayFilterTransformer.php @@ -23,10 +23,8 @@ * Array filtering transformer, should match native array_filter behavior. * * @see https://secure.php.net/manual/fr/function.array-filter.php - * - * @final since 5.4 */ -class ArrayFilterTransformer implements ConfigurableTransformerInterface +final class ArrayFilterTransformer implements ConfigurableTransformerInterface { use ConditionTrait; diff --git a/src/Transformer/Array/ArrayFirstTransformer.php b/src/Transformer/Array/ArrayFirstTransformer.php index c8f4a993..803ca93b 100644 --- a/src/Transformer/Array/ArrayFirstTransformer.php +++ b/src/Transformer/Array/ArrayFirstTransformer.php @@ -22,10 +22,8 @@ * * A non-iterable input throws an exception, unless the "allow_not_iterable" option is true: it is then returned * unchanged. - * - * @final since 5.4 */ -class ArrayFirstTransformer implements ConfigurableTransformerInterface +final class ArrayFirstTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. diff --git a/src/Transformer/Array/ArrayLastTransformer.php b/src/Transformer/Array/ArrayLastTransformer.php index fb37259f..b578a169 100644 --- a/src/Transformer/Array/ArrayLastTransformer.php +++ b/src/Transformer/Array/ArrayLastTransformer.php @@ -17,10 +17,8 @@ /** * Return the last element of an array. - * - * @final since 5.4 */ -class ArrayLastTransformer implements TransformerInterface +final class ArrayLastTransformer implements TransformerInterface { /** * @param array $options diff --git a/src/Transformer/Array/ArrayMapTransformer.php b/src/Transformer/Array/ArrayMapTransformer.php index 67f9ddbb..4da2021f 100644 --- a/src/Transformer/Array/ArrayMapTransformer.php +++ b/src/Transformer/Array/ArrayMapTransformer.php @@ -15,21 +15,19 @@ use CleverAge\ProcessBundle\Exception\TransformerException; use CleverAge\ProcessBundle\Exception\UnexpectedValueException; -use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface; use CleverAge\ProcessBundle\Transformer\TransformerTrait; use Symfony\Component\OptionsResolver\OptionsResolver; /** * Applies transformers to each element of an array. - * - * @final since 5.4 */ -class ArrayMapTransformer implements ConfigurableTransformerInterface +final class ArrayMapTransformer implements ConfigurableTransformerInterface { use TransformerTrait; - public function __construct(TransformerRegistry $transformerRegistry) + public function __construct(TransformerRegistryInterface $transformerRegistry) { $this->transformerRegistry = $transformerRegistry; } diff --git a/src/Transformer/Array/ArrayUnsetTransformer.php b/src/Transformer/Array/ArrayUnsetTransformer.php index 68fa4121..361d5f22 100644 --- a/src/Transformer/Array/ArrayUnsetTransformer.php +++ b/src/Transformer/Array/ArrayUnsetTransformer.php @@ -19,10 +19,8 @@ /** * Unset a key from an array. - * - * @final since 5.4 */ -class ArrayUnsetTransformer implements ConfigurableTransformerInterface +final class ArrayUnsetTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/CachedTransformer.php b/src/Transformer/CachedTransformer.php index ae444fa7..5bea6fd9 100644 --- a/src/Transformer/CachedTransformer.php +++ b/src/Transformer/CachedTransformer.php @@ -13,7 +13,7 @@ namespace CleverAge\ProcessBundle\Transformer; -use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use DateTime; use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\InvalidArgumentException; @@ -21,17 +21,14 @@ use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class CachedTransformer implements ConfigurableTransformerInterface +final class CachedTransformer implements ConfigurableTransformerInterface { use TransformerTrait; - final public const string CACHE_SEPARATOR = '|'; + public const string CACHE_SEPARATOR = '|'; public function __construct( - TransformerRegistry $transformerRegistry, + TransformerRegistryInterface $transformerRegistry, protected CacheItemPoolInterface $cache, protected LoggerInterface $logger, ) { diff --git a/src/Transformer/CallbackTransformer.php b/src/Transformer/CallbackTransformer.php index 69b12f16..be0eeeac 100644 --- a/src/Transformer/CallbackTransformer.php +++ b/src/Transformer/CallbackTransformer.php @@ -19,10 +19,8 @@ /** * Convert input based on a callback. - * - * @final since 5.4 */ -class CallbackTransformer implements ConfigurableTransformerInterface +final class CallbackTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. diff --git a/src/Transformer/CastTransformer.php b/src/Transformer/CastTransformer.php index 6d99ffd2..a0442539 100644 --- a/src/Transformer/CastTransformer.php +++ b/src/Transformer/CastTransformer.php @@ -17,10 +17,8 @@ /** * Cast a value to a different PHP type. - * - * @final since 5.4 */ -class CastTransformer implements ConfigurableTransformerInterface +final class CastTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/ConstantTransformer.php b/src/Transformer/ConstantTransformer.php index 0204c841..fe7c3e48 100644 --- a/src/Transformer/ConstantTransformer.php +++ b/src/Transformer/ConstantTransformer.php @@ -18,10 +18,8 @@ /** * Return always the same value configured in options, redundant when used inside mapping except in certain useful * circumstances. - * - * @final since 5.4 */ -class ConstantTransformer implements ConfigurableTransformerInterface +final class ConstantTransformer implements ConfigurableTransformerInterface { public function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Transformer/ConvertValueTransformer.php b/src/Transformer/ConvertValueTransformer.php index 5f4c6a83..5ff433e8 100644 --- a/src/Transformer/ConvertValueTransformer.php +++ b/src/Transformer/ConvertValueTransformer.php @@ -18,10 +18,8 @@ /** * Transform a value to another value based on a conversion table. - * - * @final since 5.4 */ -class ConvertValueTransformer implements ConfigurableTransformerInterface +final class ConvertValueTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. diff --git a/src/Transformer/Date/DateFormatTransformer.php b/src/Transformer/Date/DateFormatTransformer.php index d9b4c7d0..cea13383 100644 --- a/src/Transformer/Date/DateFormatTransformer.php +++ b/src/Transformer/Date/DateFormatTransformer.php @@ -24,10 +24,8 @@ * transformers: * date_format: * format: Y-m-d - * - * @final since 5.4 */ -class DateFormatTransformer implements ConfigurableTransformerInterface +final class DateFormatTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/Date/DateParserTransformer.php b/src/Transformer/Date/DateParserTransformer.php index 4869ed24..9bcbb265 100644 --- a/src/Transformer/Date/DateParserTransformer.php +++ b/src/Transformer/Date/DateParserTransformer.php @@ -24,10 +24,8 @@ * transformers: * date_parser: * format: Y-m-d - * - * @final since 5.4 */ -class DateParserTransformer implements ConfigurableTransformerInterface +final class DateParserTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/DebugTransformer.php b/src/Transformer/DebugTransformer.php index 81497c81..bc3dab82 100644 --- a/src/Transformer/DebugTransformer.php +++ b/src/Transformer/DebugTransformer.php @@ -17,10 +17,8 @@ /** * Simple dump in a transformer, passthrough for value. - * - * @final since 5.4 */ -class DebugTransformer implements TransformerInterface +final class DebugTransformer implements TransformerInterface { /** * @param array $options diff --git a/src/Transformer/DefaultTransformer.php b/src/Transformer/DefaultTransformer.php index ceba0f34..7fbd9673 100644 --- a/src/Transformer/DefaultTransformer.php +++ b/src/Transformer/DefaultTransformer.php @@ -17,10 +17,8 @@ /** * Return a default value when the input is falsy, otherwise return the input unchanged. - * - * @final since 5.4 */ -class DefaultTransformer implements ConfigurableTransformerInterface +final class DefaultTransformer implements ConfigurableTransformerInterface { public function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Transformer/EvaluatorTransformer.php b/src/Transformer/EvaluatorTransformer.php index c5d2164c..f238ee94 100644 --- a/src/Transformer/EvaluatorTransformer.php +++ b/src/Transformer/EvaluatorTransformer.php @@ -18,10 +18,7 @@ use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class EvaluatorTransformer implements ConfigurableTransformerInterface +final class EvaluatorTransformer implements ConfigurableTransformerInterface { protected ExpressionLanguage $language; diff --git a/src/Transformer/ExpressionLanguageMapTransformer.php b/src/Transformer/ExpressionLanguageMapTransformer.php index 2ac20426..8a75a525 100644 --- a/src/Transformer/ExpressionLanguageMapTransformer.php +++ b/src/Transformer/ExpressionLanguageMapTransformer.php @@ -21,10 +21,8 @@ /** * Parse an input using the Expression Language and returning a specific value upon a specific condition. - * - * @final since 5.4 */ -class ExpressionLanguageMapTransformer implements ConfigurableTransformerInterface +final class ExpressionLanguageMapTransformer implements ConfigurableTransformerInterface { public function __construct( protected ExpressionLanguage $language, diff --git a/src/Transformer/GenericTransformer.php b/src/Transformer/GenericTransformer.php index d162d75d..89f7d7d6 100644 --- a/src/Transformer/GenericTransformer.php +++ b/src/Transformer/GenericTransformer.php @@ -16,16 +16,14 @@ use CleverAge\ProcessBundle\Context\ContextualOptionResolver; use CleverAge\ProcessBundle\Exception\InvalidArgumentException; use CleverAge\ProcessBundle\Exception\LogicException; -use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; /** * A generic class that can be used to create configuration-driven transformer instances. - * - * @final since 5.4 */ -class GenericTransformer implements ConfigurableTransformerInterface +final class GenericTransformer implements ConfigurableTransformerInterface { use TransformerTrait; @@ -43,7 +41,7 @@ class GenericTransformer implements ConfigurableTransformerInterface public function __construct( protected ContextualOptionResolver $contextualOptionResolver, - TransformerRegistry $transformerRegistry, + TransformerRegistryInterface $transformerRegistry, ) { $this->transformerRegistry = $transformerRegistry; } diff --git a/src/Transformer/MappingTransformer.php b/src/Transformer/MappingTransformer.php index 1a0df746..b4273977 100644 --- a/src/Transformer/MappingTransformer.php +++ b/src/Transformer/MappingTransformer.php @@ -15,7 +15,7 @@ use CleverAge\ProcessBundle\Exception\TransformerException; use CleverAge\ProcessBundle\Exception\UnexpectedValueException; -use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use Psr\Log\LoggerInterface; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Options; @@ -26,15 +26,13 @@ /** * Maps properties of an array/object to an other array/object. - * - * @final since 5.4 */ -class MappingTransformer implements ConfigurableTransformerInterface +final class MappingTransformer implements ConfigurableTransformerInterface { use TransformerTrait; public function __construct( - TransformerRegistry $transformerRegistry, + TransformerRegistryInterface $transformerRegistry, protected LoggerInterface $logger, protected PropertyAccessorInterface $accessor, ) { diff --git a/src/Transformer/MultiReplaceTransformer.php b/src/Transformer/MultiReplaceTransformer.php index 6b285afd..ad74e4b4 100644 --- a/src/Transformer/MultiReplaceTransformer.php +++ b/src/Transformer/MultiReplaceTransformer.php @@ -22,10 +22,8 @@ * ##### Options * * * `replace_mapping` (`array`, _required_): a list of _pattern_ => _replacement_ to apply on input strings - * - * @final since 5.4 */ -class MultiReplaceTransformer implements ConfigurableTransformerInterface +final class MultiReplaceTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/Object/InstantiateTransformer.php b/src/Transformer/Object/InstantiateTransformer.php index c35717cb..4919450f 100644 --- a/src/Transformer/Object/InstantiateTransformer.php +++ b/src/Transformer/Object/InstantiateTransformer.php @@ -19,10 +19,8 @@ /** * Instantiate a new object with parameters from the input array. - * - * @final since 5.4 */ -class InstantiateTransformer implements ConfigurableTransformerInterface +final class InstantiateTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/Object/PropertyAccessorTransformer.php b/src/Transformer/Object/PropertyAccessorTransformer.php index f9bfeb47..55f63048 100644 --- a/src/Transformer/Object/PropertyAccessorTransformer.php +++ b/src/Transformer/Object/PropertyAccessorTransformer.php @@ -20,10 +20,8 @@ /** * Read a property from the input value and return it. - * - * @final since 5.4 */ -class PropertyAccessorTransformer implements ConfigurableTransformerInterface +final class PropertyAccessorTransformer implements ConfigurableTransformerInterface { public function __construct( protected PropertyAccessorInterface $accessor, diff --git a/src/Transformer/Object/RecursivePropertySetterTransformer.php b/src/Transformer/Object/RecursivePropertySetterTransformer.php index b67962ab..f166ce3f 100644 --- a/src/Transformer/Object/RecursivePropertySetterTransformer.php +++ b/src/Transformer/Object/RecursivePropertySetterTransformer.php @@ -22,10 +22,8 @@ /** * Read an iterable from the input, then set one or more properties on each of its items, using values read from the * input itself. - * - * @final since 5.4 */ -class RecursivePropertySetterTransformer implements ConfigurableTransformerInterface +final class RecursivePropertySetterTransformer implements ConfigurableTransformerInterface { public function __construct( protected PropertyAccessorInterface $accessor, diff --git a/src/Transformer/PregFilterTransformer.php b/src/Transformer/PregFilterTransformer.php index b42e7d3a..6346b049 100644 --- a/src/Transformer/PregFilterTransformer.php +++ b/src/Transformer/PregFilterTransformer.php @@ -17,18 +17,12 @@ use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class PregFilterTransformer implements ConfigurableTransformerInterface +final class PregFilterTransformer implements ConfigurableTransformerInterface { /** * @param array $options - * - * @return array|string|null */ - // @phpstan-ignore return.unusedType (narrowing the return type of a non-final class breaks the child classes, see #279) - public function transform(mixed $value, array $options = []): array|string|null + public function transform(mixed $value, array $options = []): ?string { $pattern = $options['pattern']; $replacement = $options['replacement']; diff --git a/src/Transformer/RulesTransformer.php b/src/Transformer/RulesTransformer.php index 55952034..79354400 100644 --- a/src/Transformer/RulesTransformer.php +++ b/src/Transformer/RulesTransformer.php @@ -14,7 +14,7 @@ namespace CleverAge\ProcessBundle\Transformer; use CleverAge\ProcessBundle\Exception\InvalidArgumentException; -use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\ExpressionLanguage\ParsedExpression; use Symfony\Component\OptionsResolver\Options; @@ -22,15 +22,13 @@ /** * Uses a set of rules to conditionally transform a value. - * - * @final since 5.4 */ -class RulesTransformer implements ConfigurableTransformerInterface +final class RulesTransformer implements ConfigurableTransformerInterface { use TransformerTrait; public function __construct( - TransformerRegistry $transformerRegistry, + TransformerRegistryInterface $transformerRegistry, protected ExpressionLanguage $language, ) { $this->transformerRegistry = $transformerRegistry; diff --git a/src/Transformer/Serialization/DenormalizeTransformer.php b/src/Transformer/Serialization/DenormalizeTransformer.php index 39d22f4a..14fafe92 100644 --- a/src/Transformer/Serialization/DenormalizeTransformer.php +++ b/src/Transformer/Serialization/DenormalizeTransformer.php @@ -19,10 +19,8 @@ /** * Denormalize the given value based on options. - * - * @final since 5.4 */ -class DenormalizeTransformer implements ConfigurableTransformerInterface +final class DenormalizeTransformer implements ConfigurableTransformerInterface { public function __construct( protected DenormalizerInterface $denormalizer, diff --git a/src/Transformer/Serialization/NormalizeTransformer.php b/src/Transformer/Serialization/NormalizeTransformer.php index e1b63b6e..f77e2b84 100644 --- a/src/Transformer/Serialization/NormalizeTransformer.php +++ b/src/Transformer/Serialization/NormalizeTransformer.php @@ -19,10 +19,8 @@ /** * Normalize the given value based on options. - * - * @final since 5.4 */ -class NormalizeTransformer implements ConfigurableTransformerInterface +final class NormalizeTransformer implements ConfigurableTransformerInterface { public function __construct( protected NormalizerInterface $normalizer, diff --git a/src/Transformer/String/ExplodeTransformer.php b/src/Transformer/String/ExplodeTransformer.php index c38a739f..84311c8a 100644 --- a/src/Transformer/String/ExplodeTransformer.php +++ b/src/Transformer/String/ExplodeTransformer.php @@ -18,10 +18,8 @@ /** * Explode a string to an array based on a split character. - * - * @final since 5.4 */ -class ExplodeTransformer implements ConfigurableTransformerInterface +final class ExplodeTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/String/HashTransformer.php b/src/Transformer/String/HashTransformer.php index 4a624d76..8d4f68f6 100644 --- a/src/Transformer/String/HashTransformer.php +++ b/src/Transformer/String/HashTransformer.php @@ -19,10 +19,8 @@ /** * Use hash() function to generate hash value. - * - * @final since 5.4 */ -class HashTransformer implements ConfigurableTransformerInterface +final class HashTransformer implements ConfigurableTransformerInterface { public function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Transformer/String/ImplodeTransformer.php b/src/Transformer/String/ImplodeTransformer.php index 0bbbf62d..169787ed 100644 --- a/src/Transformer/String/ImplodeTransformer.php +++ b/src/Transformer/String/ImplodeTransformer.php @@ -19,10 +19,8 @@ /** * Implode multiple array values to a string, based on a split character. - * - * @final since 5.4 */ -class ImplodeTransformer implements ConfigurableTransformerInterface +final class ImplodeTransformer implements ConfigurableTransformerInterface { public function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Transformer/String/PregMatchTransformer.php b/src/Transformer/String/PregMatchTransformer.php index 4a521793..2c5debd5 100644 --- a/src/Transformer/String/PregMatchTransformer.php +++ b/src/Transformer/String/PregMatchTransformer.php @@ -20,10 +20,8 @@ /** * Perform a regular expression match. - * - * @final since 5.4 */ -class PregMatchTransformer implements ConfigurableTransformerInterface +final class PregMatchTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/String/SlugifyTransformer.php b/src/Transformer/String/SlugifyTransformer.php index 6f10ed65..2a32a364 100644 --- a/src/Transformer/String/SlugifyTransformer.php +++ b/src/Transformer/String/SlugifyTransformer.php @@ -22,10 +22,8 @@ /** * Slugify a value. - * - * @final since 5.4 */ -class SlugifyTransformer implements ConfigurableTransformerInterface +final class SlugifyTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/String/SprintfTransformer.php b/src/Transformer/String/SprintfTransformer.php index 7b6f9fd6..570af3ca 100644 --- a/src/Transformer/String/SprintfTransformer.php +++ b/src/Transformer/String/SprintfTransformer.php @@ -19,10 +19,8 @@ /** * Use sprintf() function to format string. - * - * @final since 5.4 */ -class SprintfTransformer implements ConfigurableTransformerInterface +final class SprintfTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/String/TrimTransformer.php b/src/Transformer/String/TrimTransformer.php index 26974cff..ff5f675f 100644 --- a/src/Transformer/String/TrimTransformer.php +++ b/src/Transformer/String/TrimTransformer.php @@ -18,10 +18,8 @@ /** * Trim an input based on specific characters. - * - * @final since 5.4 */ -class TrimTransformer implements ConfigurableTransformerInterface +final class TrimTransformer implements ConfigurableTransformerInterface { /** * @param array $options diff --git a/src/Transformer/TransformerTrait.php b/src/Transformer/TransformerTrait.php index e4d391d8..be93e346 100644 --- a/src/Transformer/TransformerTrait.php +++ b/src/Transformer/TransformerTrait.php @@ -16,14 +16,14 @@ use CleverAge\ProcessBundle\Exception\InvalidArgumentException; use CleverAge\ProcessBundle\Exception\LogicException; use CleverAge\ProcessBundle\Exception\TransformerException; -use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use Closure; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; trait TransformerTrait { - protected ?TransformerRegistry $transformerRegistry = null; + protected ?TransformerRegistryInterface $transformerRegistry = null; /** * Transform the list of transformer codes + options into a list of Closure (better performances). @@ -168,9 +168,9 @@ private function parseListedTransformer(mixed $transformerDefinition, int $posit throw new InvalidArgumentException("Transformer at position {$position} is invalid : found {$type}, expected a transformer code or a single \"code: options\" map"); } - private function getTransformerRegistry(): TransformerRegistry + private function getTransformerRegistry(): TransformerRegistryInterface { - if (!$this->transformerRegistry instanceof TransformerRegistry) { + if (!$this->transformerRegistry instanceof TransformerRegistryInterface) { throw new LogicException('No transformer registry defined'); } diff --git a/src/Transformer/TypeSetterTransformer.php b/src/Transformer/TypeSetterTransformer.php index 906ee4fa..f939a1e0 100644 --- a/src/Transformer/TypeSetterTransformer.php +++ b/src/Transformer/TypeSetterTransformer.php @@ -15,10 +15,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class TypeSetterTransformer implements ConfigurableTransformerInterface +final class TypeSetterTransformer implements ConfigurableTransformerInterface { public function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Transformer/UnsetTransformer.php b/src/Transformer/UnsetTransformer.php index c6b22dbd..208bb4b8 100644 --- a/src/Transformer/UnsetTransformer.php +++ b/src/Transformer/UnsetTransformer.php @@ -19,10 +19,8 @@ /** * Unset a given property. - * - * @final since 5.4 */ -class UnsetTransformer implements ConfigurableTransformerInterface +final class UnsetTransformer implements ConfigurableTransformerInterface { use ConditionTrait; diff --git a/src/Transformer/WrapperTransformer.php b/src/Transformer/WrapperTransformer.php index cc0dfccf..a9c3074b 100644 --- a/src/Transformer/WrapperTransformer.php +++ b/src/Transformer/WrapperTransformer.php @@ -15,10 +15,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * @final since 5.4 - */ -class WrapperTransformer implements ConfigurableTransformerInterface +final class WrapperTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. diff --git a/src/Transformer/Xml/XpathEvaluatorTransformer.php b/src/Transformer/Xml/XpathEvaluatorTransformer.php index 3c626297..0ea9c399 100644 --- a/src/Transformer/Xml/XpathEvaluatorTransformer.php +++ b/src/Transformer/Xml/XpathEvaluatorTransformer.php @@ -22,10 +22,8 @@ /** * Manipulate XML elements using xpath. - * - * @final since 5.4 */ -class XpathEvaluatorTransformer implements ConfigurableTransformerInterface +final class XpathEvaluatorTransformer implements ConfigurableTransformerInterface { public function configureOptions(OptionsResolver $resolver): void { diff --git a/src/Validator/ConstraintLoader.php b/src/Validator/ConstraintLoader.php index 81971e4c..42177097 100644 --- a/src/Validator/ConstraintLoader.php +++ b/src/Validator/ConstraintLoader.php @@ -16,10 +16,7 @@ use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AbstractLoader; -/** - * @final since 5.4 - */ -class ConstraintLoader extends AbstractLoader +final class ConstraintLoader extends AbstractLoader { public function loadClassMetadata(ClassMetadata $metadata): bool { diff --git a/tests/App/DecoratingProcessConfigurationRegistry.php b/tests/App/DecoratingProcessConfigurationRegistry.php new file mode 100644 index 00000000..c9bae7e5 --- /dev/null +++ b/tests/App/DecoratingProcessConfigurationRegistry.php @@ -0,0 +1,70 @@ + */ + public array $calls = []; + + public function __construct( + private readonly ProcessConfigurationRegistryInterface $inner, + ) { + } + + public function getProcessConfiguration(string $processCode): ProcessConfiguration + { + $this->count(__FUNCTION__); + + return $this->inner->getProcessConfiguration($processCode); + } + + public function getProcessConfigurations(): array + { + $this->count(__FUNCTION__); + + return $this->inner->getProcessConfigurations(); + } + + public function hasProcessConfiguration(string $processCode): bool + { + $this->count(__FUNCTION__); + + return $this->inner->hasProcessConfiguration($processCode); + } + + public function getProcessCodes(): array + { + $this->count(__FUNCTION__); + + return $this->inner->getProcessCodes(); + } + + public function reset(): void + { + $this->count(__FUNCTION__); + $this->inner->reset(); + } + + private function count(string $method): void + { + $this->calls[$method] = ($this->calls[$method] ?? 0) + 1; + } +} diff --git a/tests/App/DecoratingProcessManager.php b/tests/App/DecoratingProcessManager.php new file mode 100644 index 00000000..15bc8619 --- /dev/null +++ b/tests/App/DecoratingProcessManager.php @@ -0,0 +1,64 @@ + */ + public array $calls = []; + + public function __construct( + private readonly ProcessManagerInterface $inner, + ) { + } + + public function execute(string $processCode, mixed $input = null, array $context = []): mixed + { + $this->count(__FUNCTION__); + + return $this->inner->execute($processCode, $input, $context); + } + + public function getProcessHistory(): ?ProcessHistory + { + $this->count(__FUNCTION__); + + return $this->inner->getProcessHistory(); + } + + public function getTaskConfiguration(): ?TaskConfiguration + { + $this->count(__FUNCTION__); + + return $this->inner->getTaskConfiguration(); + } + + public function reset(): void + { + $this->count(__FUNCTION__); + $this->inner->reset(); + } + + private function count(string $method): void + { + $this->calls[$method] = ($this->calls[$method] ?? 0) + 1; + } +} diff --git a/tests/App/DecoratingTransformerRegistry.php b/tests/App/DecoratingTransformerRegistry.php new file mode 100644 index 00000000..144066dd --- /dev/null +++ b/tests/App/DecoratingTransformerRegistry.php @@ -0,0 +1,64 @@ + */ + public array $calls = []; + + public function __construct( + private readonly TransformerRegistryInterface $inner, + ) { + } + + public function getTransformers(): array + { + $this->count(__FUNCTION__); + + return $this->inner->getTransformers(); + } + + public function getTransformerCodes(): array + { + $this->count(__FUNCTION__); + + return $this->inner->getTransformerCodes(); + } + + public function getTransformer(string $code): TransformerInterface + { + $this->count(__FUNCTION__); + + return $this->inner->getTransformer($code); + } + + public function hasTransformer(string $code): bool + { + $this->count(__FUNCTION__); + + return $this->inner->hasTransformer($code); + } + + private function count(string $method): void + { + $this->calls[$method] = ($this->calls[$method] ?? 0) + 1; + } +} diff --git a/tests/App/TestKernel.php b/tests/App/TestKernel.php index 9f986392..f5766a7e 100644 --- a/tests/App/TestKernel.php +++ b/tests/App/TestKernel.php @@ -27,6 +27,8 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\HttpKernel\Kernel; +use function Symfony\Component\DependencyInjection\Loader\Configurator\service; + /** * Application used by the integration tests: the bundle with FrameworkBundle, a process referencing every task of the * bundle by its code and a process to run, in a temporary directory of its own (per PHP process). @@ -183,6 +185,17 @@ protected function configureContainer(ContainerConfigurator $container): void $services->alias('test.transformer_registry', TransformerRegistry::class)->public(); $services->alias('test.process_configuration_registry', ProcessConfigurationRegistry::class)->public(); $services->alias('test.process_manager', ProcessManager::class)->public(); + + // The services of the bundle decorated by the application (see DecorationTest) + if ('decorated' === $this->environment) { + foreach ([ + 'cleverage_process.manager.process' => DecoratingProcessManager::class, + 'cleverage_process.registry.process_configuration' => DecoratingProcessConfigurationRegistry::class, + 'cleverage_process.registry.transformer' => DecoratingTransformerRegistry::class, + ] as $id => $class) { + $services->set($class)->decorate($id)->args([service('.inner')])->public(); + } + } } private function getRunDir(): string diff --git a/tests/CleverAgeProcessBundleTest.php b/tests/CleverAgeProcessBundleTest.php index e1ce3fd7..7e0f9d68 100644 --- a/tests/CleverAgeProcessBundleTest.php +++ b/tests/CleverAgeProcessBundleTest.php @@ -50,21 +50,4 @@ public function testPath(): void { self::assertSame(\dirname(__DIR__), (new CleverAgeProcessBundle())->getPath()); } - - /** - * A class extending the bundle (deprecated, @final since 5.4) in another directory still loads its services. - */ - public function testSubclassLoadsTheServicesOfTheBundle(): void - { - // @phpstan-ignore class.extendsFinalByPhpDoc - $bundle = new class extends CleverAgeProcessBundle {}; - $container = new ContainerBuilder(); - $container->setParameter('kernel.environment', 'test'); - $container->setParameter('kernel.build_dir', sys_get_temp_dir()); - - $bundle->getContainerExtension()->load([], $container); - - self::assertSame(\dirname(__DIR__), $bundle->getPath()); - self::assertTrue($container->hasDefinition('cleverage_process.manager.process')); - } } diff --git a/tests/Command/ExecuteProcessCommandTest.php b/tests/Command/ExecuteProcessCommandTest.php index a36f3447..d4c41a93 100644 --- a/tests/Command/ExecuteProcessCommandTest.php +++ b/tests/Command/ExecuteProcessCommandTest.php @@ -18,7 +18,7 @@ use CleverAge\ProcessBundle\Configuration\TaskConfiguration; use CleverAge\ProcessBundle\Event\ConsoleProcessEvent; use CleverAge\ProcessBundle\Filesystem\JsonStreamFile; -use CleverAge\ProcessBundle\Manager\ProcessManager; +use CleverAge\ProcessBundle\Manager\ProcessManagerInterface; use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -201,7 +201,7 @@ public function testNoWarningWithoutInput(): void public function testTheProcessCodesAndTheOutputFormatsAreCompleted(): void { - $processManager = $this->createStub(ProcessManager::class); + $processManager = $this->createStub(ProcessManagerInterface::class); $registry = new ProcessConfigurationRegistry( ['test.process' => ['options' => [], 'entry_point' => null, 'end_point' => null, 'description' => '', 'help' => '', 'public' => false, 'tasks' => []]], 'stop' @@ -229,7 +229,7 @@ public function log($level, \Stringable|string $message, array $context = []): v }; $process = ['options' => [], 'entry_point' => null, 'end_point' => null, 'description' => '', 'help' => '', 'public' => true, 'tasks' => []]; $registry = new ProcessConfigurationRegistry(['test.invalid' => ['entry_point' => 'missing'] + $process, 'test.valid' => $process], 'stop', [], $logger); - $tester = new CommandCompletionTester(new ExecuteProcessCommand($this->createStub(ProcessManager::class), new EventDispatcher(), $registry)); + $tester = new CommandCompletionTester(new ExecuteProcessCommand($this->createStub(ProcessManagerInterface::class), new EventDispatcher(), $registry)); self::assertSame(['test.invalid', 'test.valid'], $tester->complete([''])); self::assertSame([], $logger->records); @@ -237,7 +237,7 @@ public function log($level, \Stringable|string $message, array $context = []): v private function createTester(\PHPUnit\Framework\MockObject\Rule\InvocationOrder $executions, mixed $result = null): CommandTester { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects($executions)->method('execute')->willReturn($result); $registry = new ProcessConfigurationRegistry( [ diff --git a/tests/EventListener/SignalStopCheckerTest.php b/tests/EventListener/SignalStopCheckerTest.php index 87a5ff2f..66c64313 100644 --- a/tests/EventListener/SignalStopCheckerTest.php +++ b/tests/EventListener/SignalStopCheckerTest.php @@ -13,12 +13,15 @@ namespace CleverAge\ProcessBundle\Tests\EventListener; +use CleverAge\ProcessBundle\Configuration\ProcessConfiguration; use CleverAge\ProcessBundle\EventListener\SignalStopChecker; +use CleverAge\ProcessBundle\Model\ProcessHistory; use CleverAge\ProcessBundle\Model\ProcessState; use Monolog\Handler\TestHandler; use Monolog\Logger; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Event\ConsoleSignalEvent; @@ -26,6 +29,9 @@ use Symfony\Component\Console\Output\NullOutput; #[CoversClass(SignalStopChecker::class)] +#[UsesClass(ProcessConfiguration::class)] +#[UsesClass(ProcessHistory::class)] +#[UsesClass(ProcessState::class)] #[RequiresPhpExtension('pcntl')] class SignalStopCheckerTest extends TestCase { @@ -37,14 +43,14 @@ public function testSignalWithoutRunningProcessExits(): void $checker->onConsoleSignal($event); self::assertSame(0, $event->getExitCode()); - self::assertFalse($checker->shouldStop($this->createStub(ProcessState::class))); + self::assertFalse($checker->shouldStop($this->createState())); } public function testSignalDuringAProcessStopsIt(): void { $checker = new SignalStopChecker(new Logger('cleverage_process', [$logs = new TestHandler()])); $checker->onProcessStart(); - $state = $this->createStub(ProcessState::class); + $state = $this->createState(); self::assertFalse($checker->shouldStop($state)); $event = $this->createEvent(\SIGTERM); @@ -120,7 +126,7 @@ public function testSameSignalReceivedAgainKeepsAnAbortedExit(): void public function testStopRequestIsKeptUntilReset(): void { $checker = new SignalStopChecker(new Logger('cleverage_process', [$logs = new TestHandler()])); - $state = $this->createStub(ProcessState::class); + $state = $this->createState(); $checker->onProcessStart(); $checker->onProcessStart(); // sub-process $checker->onConsoleSignal($this->createEvent(\SIGINT)); @@ -150,11 +156,18 @@ public function testOtherSignalsAreIgnored(): void $checker->onConsoleSignal($event); self::assertSame(0, $event->getExitCode()); - self::assertFalse($checker->shouldStop($this->createStub(ProcessState::class))); + self::assertFalse($checker->shouldStop($this->createState())); } private function createEvent(int $signal): ConsoleSignalEvent { return new ConsoleSignalEvent(new Command('test'), new ArrayInput([]), new NullOutput(), $signal); } + + private function createState(): ProcessState + { + $processConfiguration = new ProcessConfiguration('test.process', []); + + return new ProcessState($processConfiguration, new ProcessHistory($processConfiguration)); + } } diff --git a/tests/Functional/DecorationTest.php b/tests/Functional/DecorationTest.php new file mode 100644 index 00000000..6a64c530 --- /dev/null +++ b/tests/Functional/DecorationTest.php @@ -0,0 +1,104 @@ + 'decorated'])))->find('cleverage:process:execute'); + $tester = new CommandTester($command); + + self::assertSame(0, $tester->execute(['processCodes' => ['test.run']])); + + // The command, the process manager and the transformer task use the decorators + self::assertGreaterThanOrEqual(1, $this->getProcessManager()->calls['execute'] ?? 0); + self::assertGreaterThanOrEqual(1, $this->getProcessConfigurationRegistry()->calls['getProcessConfiguration'] ?? 0); + self::assertGreaterThanOrEqual(1, $this->getTransformerRegistry()->calls['getTransformer'] ?? 0); + } + + /** + * Every service of the bundle receiving the process manager or a registry (commands, tasks, transformers, Monolog + * processors) accepts the decorators: the types of the arguments are checked against the decorators. + */ + public function testEveryServiceAcceptsTheDecorators(): void + { + $command = (new Application(self::bootKernel(['environment' => 'decorated'])))->find('lint:container'); + $tester = new CommandTester($command); + + self::assertSame(0, $tester->execute([]), $tester->getDisplay()); + } + + public function testTheResetGoesThroughTheDecorators(): void + { + self::bootKernel(['environment' => 'decorated']); + $processManager = $this->getProcessManager(); + self::assertSame('Hello world', $processManager->execute('test.run')); + + // As between two messages of a worker + $resetter = self::getContainer()->get('services_resetter'); + self::assertInstanceOf(ResetInterface::class, $resetter); + $resetter->reset(); + + self::assertSame(1, $processManager->calls['reset'] ?? 0); + self::assertSame(1, $this->getProcessConfigurationRegistry()->calls['reset'] ?? 0); + // The services of the bundle are still usable after their reset + self::assertSame('Hello world', $processManager->execute('test.run')); + } + + protected static function getKernelClass(): string + { + return TestKernel::class; + } + + private function getProcessManager(): DecoratingProcessManager + { + $service = self::getContainer()->get(DecoratingProcessManager::class); + self::assertInstanceOf(DecoratingProcessManager::class, $service); + + return $service; + } + + private function getProcessConfigurationRegistry(): DecoratingProcessConfigurationRegistry + { + $service = self::getContainer()->get(DecoratingProcessConfigurationRegistry::class); + self::assertInstanceOf(DecoratingProcessConfigurationRegistry::class, $service); + + return $service; + } + + private function getTransformerRegistry(): DecoratingTransformerRegistry + { + $service = self::getContainer()->get(DecoratingTransformerRegistry::class); + self::assertInstanceOf(DecoratingTransformerRegistry::class, $service); + + return $service; + } +} diff --git a/tests/Logger/ProcessorsTest.php b/tests/Logger/ProcessorsTest.php index ed6442b8..56340c75 100644 --- a/tests/Logger/ProcessorsTest.php +++ b/tests/Logger/ProcessorsTest.php @@ -19,7 +19,7 @@ use CleverAge\ProcessBundle\Logger\ProcessProcessor; use CleverAge\ProcessBundle\Logger\TaskProcessor; use CleverAge\ProcessBundle\Logger\TransformerProcessor; -use CleverAge\ProcessBundle\Manager\ProcessManager; +use CleverAge\ProcessBundle\Manager\ProcessManagerInterface; use CleverAge\ProcessBundle\Model\ProcessHistory; use CleverAge\ProcessBundle\Model\ProcessState; use Monolog\Level; @@ -43,7 +43,7 @@ class ProcessorsTest extends TestCase { public function testNothingIsAddedOutsideOfAProcess(): void { - $processManager = $this->createStub(ProcessManager::class); + $processManager = $this->createStub(ProcessManagerInterface::class); foreach ([ProcessProcessor::class, TaskProcessor::class, TransformerProcessor::class] as $class) { $record = (new $class($processManager))($this->createRecord(['foo' => 'bar'])); @@ -92,7 +92,7 @@ public function testTheTaskAndTransformerProcessorsAddTheTaskAndItsError(): void } /** - * @return array{ProcessManager, ProcessHistory, ProcessState} + * @return array{ProcessManagerInterface, ProcessHistory, ProcessState} */ private function createProcessManager(): array { @@ -102,7 +102,7 @@ private function createProcessManager(): array $state = new ProcessState($processConfiguration, $history); $taskConfiguration->setState($state); - $processManager = $this->createStub(ProcessManager::class); + $processManager = $this->createStub(ProcessManagerInterface::class); $processManager->method('getProcessHistory')->willReturn($history); $processManager->method('getTaskConfiguration')->willReturn($taskConfiguration); diff --git a/tests/Registry/TransformerRegistryTest.php b/tests/Registry/TransformerRegistryTest.php index 204885a6..a6fef8b2 100644 --- a/tests/Registry/TransformerRegistryTest.php +++ b/tests/Registry/TransformerRegistryTest.php @@ -54,6 +54,24 @@ public function testMissingTransformerThrows(): void $this->createRegistry()->getTransformer('unknown'); } + /** + * Only the transformers of the locator are given, whatever was fetched before: a missing code is not kept. + */ + public function testOnlyTheTransformersOfTheLocatorAreGiven(): void + { + $registry = $this->createRegistry(); + $registry->getTransformer('trim'); + try { + $registry->getTransformer('unknown'); + self::fail('A missing transformer throws'); + } catch (MissingTransformerException) { + } + + self::assertFalse($registry->hasTransformer('unknown')); + self::assertSame(['trim', 'cast'], $registry->getTransformerCodes()); + self::assertSame(['trim', 'cast'], array_keys($registry->getTransformers())); + } + /** * The code is the one of the locator: a transformer can be registered under several codes. */ @@ -69,26 +87,6 @@ public function testTheCodeIsTheOneOfTheLocator(): void self::assertSame($transformer, $registry->getTransformer('trim')); } - /** - * A transformer added to the cache by a subclass, outside of the locator, is not given (as by hasTransformer()). - */ - public function testOnlyTheTransformersOfTheLocatorAreGiven(): void - { - // @phpstan-ignore class.extendsFinalByPhpDoc (a subclass, deprecated since 5.4 but still possible, is the case tested) - $registry = new class(new ServiceLocator([])) extends TransformerRegistry { - public function addToCache(string $code, TransformerInterface $transformer): void - { - $this->transformers[$code] = $transformer; - } - }; - $registry->addToCache('trim', new TrimTransformer()); - - self::assertFalse($registry->hasTransformer('trim')); - $this->expectException(MissingTransformerException::class); - - $registry->getTransformer('trim'); - } - public function testServiceMustBeATransformer(): void { $registry = new TransformerRegistry(new ServiceLocator(['trim' => static fn (): \stdClass => new \stdClass()])); diff --git a/tests/Task/Process/ProcessExecutorTaskTest.php b/tests/Task/Process/ProcessExecutorTaskTest.php index 01c02c38..eec02b73 100644 --- a/tests/Task/Process/ProcessExecutorTaskTest.php +++ b/tests/Task/Process/ProcessExecutorTaskTest.php @@ -16,7 +16,7 @@ use CleverAge\ProcessBundle\Configuration\ProcessConfiguration; use CleverAge\ProcessBundle\Configuration\TaskConfiguration; use CleverAge\ProcessBundle\Context\ContextualOptionResolver; -use CleverAge\ProcessBundle\Manager\ProcessManager; +use CleverAge\ProcessBundle\Manager\ProcessManagerInterface; use CleverAge\ProcessBundle\Model\AbstractConfigurableTask; use CleverAge\ProcessBundle\Model\ProcessHistory; use CleverAge\ProcessBundle\Model\ProcessState; @@ -42,7 +42,7 @@ class ProcessExecutorTaskTest extends TestCase { public function testInputIsPassedToTheSubProcessAndItsOutputIsForwarded(): void { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects(self::once()) ->method('execute') ->with('child', ['id' => 1], []) @@ -56,7 +56,7 @@ public function testInputIsPassedToTheSubProcessAndItsOutputIsForwarded(): void public function testEachInputExecutesTheSubProcess(): void { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects(self::exactly(2)) ->method('execute') ->willReturnCallback(static fn (string $code, mixed $input): string => $code.':'.$input); @@ -76,7 +76,7 @@ public function testEachInputExecutesTheSubProcess(): void public function testNullSubProcessOutputIsForwarded(): void { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects(self::once())->method('execute')->willReturn(null); $state = $this->execute($processManager, ['process' => 'child'], 'foo'); @@ -86,7 +86,7 @@ public function testNullSubProcessOutputIsForwarded(): void public function testContextOptionIsPassedToTheSubProcess(): void { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects(self::once()) ->method('execute') ->with('child', 'foo', ['source' => 'import.csv', 'mode' => 'full']) @@ -104,7 +104,7 @@ public function testContextOptionIsPassedToTheSubProcess(): void public function testProcessCodeIsContextualized(): void { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects(self::once())->method('execute')->with('child', 'foo', [])->willReturn('done'); $state = $this->execute($processManager, ['process' => '{{ sub }}'], 'foo', ['sub' => 'child']); @@ -114,7 +114,7 @@ public function testProcessCodeIsContextualized(): void public function testSubProcessExceptionIsPropagated(): void { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects(self::once())->method('execute')->willThrowException(new \RuntimeException('Sub-process failed')); $this->expectException(\RuntimeException::class); @@ -124,7 +124,7 @@ public function testSubProcessExceptionIsPropagated(): void public function testUnknownProcessThrowsAtInitialization(): void { - $processManager = $this->createMock(ProcessManager::class); + $processManager = $this->createMock(ProcessManagerInterface::class); $processManager->expects(self::never())->method('execute'); $this->expectException(InvalidConfigurationException::class); @@ -151,14 +151,14 @@ public static function invalidOptionsProvider(): iterable public function testInvalidOptionsThrowAtInitialization(array $options, string $exception): void { $this->expectException($exception); - $this->createTask($this->createStub(ProcessManager::class))->initialize($this->createState($options, 'foo')); + $this->createTask($this->createStub(ProcessManagerInterface::class))->initialize($this->createState($options, 'foo')); } /** * @param array $options * @param array $context */ - private function execute(ProcessManager $processManager, array $options, mixed $input, array $context = []): ProcessState + private function execute(ProcessManagerInterface $processManager, array $options, mixed $input, array $context = []): ProcessState { $state = $this->createState($options, $input, $context); $task = $this->createTask($processManager); @@ -168,7 +168,7 @@ private function execute(ProcessManager $processManager, array $options, mixed $ return $state; } - private function createTask(ProcessManager $processManager): ProcessExecutorTask + private function createTask(ProcessManagerInterface $processManager): ProcessExecutorTask { return new ProcessExecutorTask( $processManager, diff --git a/tests/Task/Process/ProcessLauncherTaskTest.php b/tests/Task/Process/ProcessLauncherTaskTest.php index 2d987f2d..362e2ec7 100644 --- a/tests/Task/Process/ProcessLauncherTaskTest.php +++ b/tests/Task/Process/ProcessLauncherTaskTest.php @@ -21,7 +21,7 @@ use CleverAge\ProcessBundle\Model\ProcessHistory; use CleverAge\ProcessBundle\Model\ProcessState; use CleverAge\ProcessBundle\Model\SubprocessInstance; -use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; +use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistryInterface; use CleverAge\ProcessBundle\Task\Process\ProcessLauncherTask; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; @@ -330,9 +330,9 @@ private function createTask(): ProcessLauncherTask return new ProcessLauncherTask(new NullLogger(), $this->createRegistry(), '/app/bin/console', 'test'); } - private function createRegistry(): ProcessConfigurationRegistry + private function createRegistry(): ProcessConfigurationRegistryInterface { - $registry = $this->createStub(ProcessConfigurationRegistry::class); + $registry = $this->createStub(ProcessConfigurationRegistryInterface::class); $registry->method('hasProcessConfiguration')->willReturnCallback( static fn (string $processCode): bool => 'child' === $processCode ); diff --git a/tests/Transformer/CachedTransformerTest.php b/tests/Transformer/CachedTransformerTest.php index 84cf0027..eb87e79d 100644 --- a/tests/Transformer/CachedTransformerTest.php +++ b/tests/Transformer/CachedTransformerTest.php @@ -14,6 +14,7 @@ namespace CleverAge\ProcessBundle\Tests\Transformer; use CleverAge\ProcessBundle\Registry\TransformerRegistry; +use CleverAge\ProcessBundle\Registry\TransformerRegistryInterface; use CleverAge\ProcessBundle\Transformer\CachedTransformer; use CleverAge\ProcessBundle\Transformer\CastTransformer; use CleverAge\ProcessBundle\Transformer\TransformerInterface; @@ -178,7 +179,7 @@ public function testFailureToSaveIsLogged(): void $cache->method('getItem')->willReturn($item); $cache->expects(self::once())->method('saveDeferred')->with($item)->willReturn(false); $logs = new TestHandler(); - $transformer = new CachedTransformer($this->createStub(TransformerRegistry::class), $cache, new Logger('test', [$logs])); + $transformer = new CachedTransformer($this->createStub(TransformerRegistryInterface::class), $cache, new Logger('test', [$logs])); self::assertSame('a', $transformer->transform('a', ['cache_key' => 'prefix', 'transformers' => [], 'key_transformers' => [], 'ttl' => null])); self::assertTrue($logs->hasWarning(['message' => 'Cannot save cache item', 'context' => ['cache_key' => 'prefix|a']])); @@ -191,7 +192,7 @@ public function testNonStringKeyValueDoesNotUseTheCache(): void { $cache = $this->createMock(CacheItemPoolInterface::class); $cache->expects(self::never())->method('getItem'); - $transformer = new CachedTransformer($this->createStub(TransformerRegistry::class), $cache, new NullLogger()); + $transformer = new CachedTransformer($this->createStub(TransformerRegistryInterface::class), $cache, new NullLogger()); self::assertSame(42, $transformer->transform(42, ['cache_key' => 'prefix', 'transformers' => [], 'key_transformers' => [], 'ttl' => null])); }