diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a8ae6b0..bdf7f535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Latest ## Changes * [#197](https://github.com/cleverage/process-bundle/issues/197) Add missing tests: every Task and Transformer is now covered by unit tests. Remove the obsolete `tests.old` directory. +* [#143](https://github.com/cleverage/process-bundle/issues/143) Improve PHPStan configuration: remove all `ignoreErrors` and `@phpstan-ignore` comments (report unmatched ignored errors again), add missing iterable value types and generic types in PHPDoc, remove unreachable code in AbstractIterableOutputTask and InputAggregatorTask. + +## Fixes +* [#143](https://github.com/cleverage/process-bundle/issues/143) Fix InputIteratorTask: an `\IteratorAggregate` input whose `getIterator()` does not return an `\Iterator` (e.g. another `\IteratorAggregate`) is iterated instead of failing with a `TypeError`. Update documentation, add tests. v5.1 ----- diff --git a/docs/reference/tasks/input_iterator_task.md b/docs/reference/tasks/input_iterator_task.md index 6451f86d..2d4407ce 100644 --- a/docs/reference/tasks/input_iterator_task.md +++ b/docs/reference/tasks/input_iterator_task.md @@ -12,7 +12,7 @@ Task reference Accepted inputs --------------- -`array`, `\Iterator` or `\IteratorAggregate`: any other type throws an `\UnexpectedValueException` +`array`, `\Iterator` or `\IteratorAggregate` (whatever `\Traversable` its `getIterator()` returns): any other type throws an `\UnexpectedValueException` Possible outputs ---------------- diff --git a/phpstan.neon b/phpstan.neon index f0560a73..337ea110 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,16 +5,5 @@ parameters: - tests excludePaths: - src/Resources/tests/* - ignoreErrors: - - '#type has no value type specified in iterable type#' - - '#has parameter .* with no value type specified in iterable type#' - - '#has no value type specified in iterable type array#' - - '#configureOptions\(\) has no return type specified.#' - - '#configure\(\) has no return type specified#' - - '#process\(\) has no return type specified#' - - '#should return Iterator but returns Traversable#' - - '#Negated boolean expression is always false#' - - identifier: missingType.generics - reportUnmatchedIgnoredErrors: false inferPrivatePropertyTypeFromConstructor: true treatPhpDocTypesAsCertain: false diff --git a/src/Command/ListProcessCommand.php b/src/Command/ListProcessCommand.php index 01fdf997..4837bda4 100644 --- a/src/Command/ListProcessCommand.php +++ b/src/Command/ListProcessCommand.php @@ -48,6 +48,9 @@ public function processSorter(ProcessConfiguration $a, ProcessConfiguration $b): return $a->getCode() <=> $b->getCode(); } + /** + * @param array{output: string} $message + */ public function maxMessageLengthFilter(int $max, array $message): int { return max($max, \strlen($this->filterOutTags($message['output']))); diff --git a/src/Command/ProcessHelpCommand.php b/src/Command/ProcessHelpCommand.php index ea22e351..5864ffad 100644 --- a/src/Command/ProcessHelpCommand.php +++ b/src/Command/ProcessHelpCommand.php @@ -126,6 +126,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * Try to find a best candidate for next display. + * + * @param array $branches + * @param list $taskList */ protected function findBestNextTask( array $branches, @@ -223,6 +226,8 @@ protected function getTaskChildrenCount(TaskConfiguration $task): int /** * Merge needed branches, display a task node, split following needed branches. + * + * @param array $branches */ protected function resolveBranchOutput( array &$branches, @@ -442,6 +447,10 @@ static function ($branchTask, $i) use ($origin, $branches, $gapBranches, $final) $this->writeBranches($output, $branches); } + /** + * @param array $branches + * @param string|iterable $comment + */ protected function writeBranches( OutputInterface $output, array $branches, diff --git a/src/Configuration/ProcessConfiguration.php b/src/Configuration/ProcessConfiguration.php index 48d9caa8..b62aa723 100644 --- a/src/Configuration/ProcessConfiguration.php +++ b/src/Configuration/ProcessConfiguration.php @@ -21,10 +21,20 @@ */ class ProcessConfiguration { + /** + * @var list>|null + */ protected ?array $dependencyGroups = null; + /** + * @var list|null + */ protected ?array $mainTaskGroup = null; + /** + * @param array $taskConfigurations + * @param array $options + */ public function __construct( protected string $code, protected array $taskConfigurations, @@ -42,6 +52,9 @@ public function getCode(): string return $this->code; } + /** + * @return array + */ public function getOptions(): array { return $this->options; @@ -106,6 +119,8 @@ public function getTaskConfiguration(string $taskCode): TaskConfiguration * Group all task by dependencies. * * If one task depend from another, it should come after + * + * @return list> */ public function getDependencyGroups(): array { @@ -130,6 +145,8 @@ public function getDependencyGroups(): array * It may be defined by the entry_point, or the end_point or simply the first task. * * If one task depend from another, it should come after + * + * @return list */ public function getMainTaskGroup(): array { @@ -195,6 +212,10 @@ public function checkCircularDependencies(): void /** * Cross all relations of a task to find all dependencies, and append them to the given array. + * + * @param list $dependencies + * + * @return list */ protected function buildDependencies(TaskConfiguration $taskConfig, array &$dependencies = []): array { @@ -222,6 +243,10 @@ protected function buildDependencies(TaskConfiguration $taskConfig, array &$depe /** * Sort the tasks by dependencies. + * + * @param list $dependencies + * + * @return list */ protected function sortDependencies(array $dependencies): array { diff --git a/src/Configuration/TaskConfiguration.php b/src/Configuration/TaskConfiguration.php index 1645939e..f6b167ce 100644 --- a/src/Configuration/TaskConfiguration.php +++ b/src/Configuration/TaskConfiguration.php @@ -49,6 +49,11 @@ class TaskConfiguration protected bool $logErrors; + /** + * @param array $options + * @param list $outputs + * @param list $errorOutputs + */ public function __construct( protected string $code, protected string $serviceReference, @@ -93,6 +98,9 @@ public function getHelp(): string return $this->help; } + /** + * @return array + */ public function getOptions(): array { return $this->options; @@ -107,11 +115,17 @@ public function getOption(string $code, mixed $default = null): mixed return $default; } + /** + * @return list + */ public function getOutputs(): array { return $this->outputs; } + /** + * @return list + */ #[\Deprecated(message: 'Use getErrorOutputs method instead')] public function getErrors(): array { @@ -120,6 +134,9 @@ public function getErrors(): array return $this->getErrorOutputs(); } + /** + * @return list + */ public function getErrorOutputs(): array { return $this->errorOutputs; diff --git a/src/Context/ContextualOptionResolver.php b/src/Context/ContextualOptionResolver.php index 067e3509..ef3014b4 100644 --- a/src/Context/ContextualOptionResolver.php +++ b/src/Context/ContextualOptionResolver.php @@ -18,6 +18,8 @@ class ContextualOptionResolver /** * Basic value inference * Replaces "{{ key }}" by context[key]. + * + * @param array $context */ public function contextualizeOption(mixed $value, array $context): mixed { @@ -46,6 +48,11 @@ public function contextualizeOption(mixed $value, array $context): mixed /** * Replace all contextualized values from options. + * + * @param array $options + * @param array $context + * + * @return array */ public function contextualizeOptions(array $options, array $context): array { diff --git a/src/Event/ConsoleProcessEvent.php b/src/Event/ConsoleProcessEvent.php index e404e071..317d0047 100644 --- a/src/Event/ConsoleProcessEvent.php +++ b/src/Event/ConsoleProcessEvent.php @@ -22,6 +22,9 @@ */ class ConsoleProcessEvent extends Event { + /** + * @param array $processContext + */ public function __construct( private readonly InputInterface $consoleInput, private readonly OutputInterface $consoleOutput, @@ -45,6 +48,9 @@ public function getProcessInput(): mixed return $this->processInput; } + /** + * @return array + */ public function getProcessContext(): array { return $this->processContext; diff --git a/src/Event/ProcessEvent.php b/src/Event/ProcessEvent.php index 6c7b297f..7e9c8f53 100644 --- a/src/Event/ProcessEvent.php +++ b/src/Event/ProcessEvent.php @@ -26,6 +26,9 @@ class ProcessEvent extends Event final public const EVENT_PROCESS_FAILED = 'cleverage_process.fail'; + /** + * @param array $processContext + */ public function __construct( protected string $processCode, protected mixed $processInput = null, @@ -50,6 +53,9 @@ public function getProcessOutput(): mixed return $this->processOutput; } + /** + * @return array + */ public function getProcessContext(): array { return $this->processContext; diff --git a/src/EventListener/DataQueueEventListener.php b/src/EventListener/DataQueueEventListener.php index b405d886..2d0de8e1 100644 --- a/src/EventListener/DataQueueEventListener.php +++ b/src/EventListener/DataQueueEventListener.php @@ -14,6 +14,7 @@ namespace CleverAge\ProcessBundle\EventListener; use CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent; +use CleverAge\ProcessBundle\Model\ProcessState; /** * Class DataQueueEventListener @@ -23,7 +24,7 @@ class DataQueueEventListener { /** - * @var \SplQueue[] + * @var array> */ protected array $queues = []; @@ -33,6 +34,9 @@ public function pushData(EventDispatcherTaskEvent $event): void $queue->push(clone $event->getState()); } + /** + * @return \SplQueue + */ public function getQueue(string $processName): \SplQueue { if (!\array_key_exists($processName, $this->queues)) { diff --git a/src/Exception/InvalidProcessConfigurationException.php b/src/Exception/InvalidProcessConfigurationException.php index aecaab1f..3366fe24 100644 --- a/src/Exception/InvalidProcessConfigurationException.php +++ b/src/Exception/InvalidProcessConfigurationException.php @@ -21,6 +21,9 @@ */ class InvalidProcessConfigurationException extends \UnexpectedValueException implements ProcessExceptionInterface { + /** + * @param list $mainTaskList + */ public static function createNotInMain( ProcessConfiguration $processConfiguration, TaskConfiguration $taskConfig, diff --git a/src/ExpressionLanguage/PhpFunctionProvider.php b/src/ExpressionLanguage/PhpFunctionProvider.php index 9a2632b7..bd931429 100644 --- a/src/ExpressionLanguage/PhpFunctionProvider.php +++ b/src/ExpressionLanguage/PhpFunctionProvider.php @@ -21,6 +21,9 @@ */ class PhpFunctionProvider implements ExpressionFunctionProviderInterface { + /** + * @param list $functions + */ public function __construct( protected array $functions, ) { diff --git a/src/Filesystem/CsvFile.php b/src/Filesystem/CsvFile.php index d8944e87..5678c00a 100644 --- a/src/Filesystem/CsvFile.php +++ b/src/Filesystem/CsvFile.php @@ -19,10 +19,10 @@ class CsvFile extends CsvResource { /** - * @param string $filePath Also accept a resource - * @param string $delimiter CSV delimiter - * @param ?array $headers Leave null to read the headers from the file - * @param string $mode Same parameter as the mode in the fopen function (r, w, a, etc.) + * @param string $filePath Also accept a resource + * @param string $delimiter CSV delimiter + * @param list|null $headers Leave null to read the headers from the file + * @param string $mode Same parameter as the mode in the fopen function (r, w, a, etc.) */ public function __construct( protected $filePath, diff --git a/src/Filesystem/CsvResource.php b/src/Filesystem/CsvResource.php index 3c536dca..4fc24d2d 100644 --- a/src/Filesystem/CsvResource.php +++ b/src/Filesystem/CsvResource.php @@ -25,6 +25,9 @@ class CsvResource implements WritableStructuredFileInterface, SeekableFileInterf protected ?int $lineCount = null; + /** + * @var list + */ protected array $headers; protected bool $manualHeaders = false; @@ -37,6 +40,9 @@ class CsvResource implements WritableStructuredFileInterface, SeekableFileInterf protected bool $seekCalled = false; + /** + * @param list|null $headers + */ public function __construct( mixed $resource, protected string $delimiter = ',', @@ -110,6 +116,9 @@ public function getLineCount(): int return $this->lineCount; } + /** + * @return list + */ public function getHeaders(): array { return $this->headers; @@ -146,6 +155,8 @@ public function isEndOfFile(): bool /** * Warning, this function will return exactly the same value as the fgetcsv() function. + * + * @return list|false */ public function readRaw(?int $length = null): array|false { @@ -155,6 +166,9 @@ public function readRaw(?int $length = null): array|false return fgetcsv($this->handler, $length, $this->delimiter, $this->enclosure, $this->escape); } + /** + * @return array|null + */ public function readLine(?int $length = null): ?array { $filePosition = $this->seekCalled ? "at position {$this->tell()}" : "on line {$this->getLineNumber()}"; @@ -186,6 +200,8 @@ public function readLine(?int $length = null): ?array /** * Warning, this function will return exactly the same value as the fgetcsv() function. + * + * @param array $fields */ public function writeRaw(array $fields): int|false { @@ -195,6 +211,9 @@ public function writeRaw(array $fields): int|false return fputcsv($this->handler, $fields, $this->delimiter, $this->enclosure, $this->escape); } + /** + * @param array $fields + */ public function writeLine(array $fields): int { $count = \count($fields); @@ -284,6 +303,11 @@ protected function assertOpened(): void } } + /** + * @param list|null $headers + * + * @return list + */ protected function parseHeaders(?array $headers = null): array { // If headers are not passed in the constructor but file is readable, try to read headers from file diff --git a/src/Filesystem/FileStreamInterface.php b/src/Filesystem/FileStreamInterface.php index 65b5b819..e319df39 100644 --- a/src/Filesystem/FileStreamInterface.php +++ b/src/Filesystem/FileStreamInterface.php @@ -27,6 +27,9 @@ public function getLineNumber(): int; public function isEndOfFile(): bool; + /** + * @return array|null + */ public function readLine(?int $length = null): ?array; /** diff --git a/src/Filesystem/JsonStreamFile.php b/src/Filesystem/JsonStreamFile.php index 6642a399..1253943d 100644 --- a/src/Filesystem/JsonStreamFile.php +++ b/src/Filesystem/JsonStreamFile.php @@ -26,6 +26,10 @@ class JsonStreamFile implements FileStreamInterface, WritableFileInterface protected int $lineNumber = 1; + /** + * @param list|null $splFileObjectFlags + * @param list|null $jsonFlags + */ public function __construct( string $filename, string $mode = 'rb', @@ -86,6 +90,8 @@ public function isEndOfFile(): bool /** * Return an array containing current data and moving the file pointer. * + * @return array|null + * * @throws \UnexpectedValueException if the line decodes to a scalar value */ public function readLine(?int $length = null): ?array @@ -109,6 +115,9 @@ public function readLine(?int $length = null): ?array return $data; } + /** + * @param array $fields + */ public function writeLine(array $fields): int { $this->file->fwrite(json_encode($fields, $this->jsonFlags).\PHP_EOL); diff --git a/src/Filesystem/SplFile.php b/src/Filesystem/SplFile.php index 14f38c40..a7f55ec8 100644 --- a/src/Filesystem/SplFile.php +++ b/src/Filesystem/SplFile.php @@ -24,6 +24,9 @@ class SplFile protected int $lineNumber = 1; + /** + * @param list|null $splFileObjectFlags + */ public function __construct( string $filename, string $mode = 'rb', diff --git a/src/Filesystem/StructuredFileInterface.php b/src/Filesystem/StructuredFileInterface.php index 15e7db2e..4da6be9a 100644 --- a/src/Filesystem/StructuredFileInterface.php +++ b/src/Filesystem/StructuredFileInterface.php @@ -18,6 +18,9 @@ */ interface StructuredFileInterface extends FileStreamInterface { + /** + * @return list + */ public function getHeaders(): array; public function getHeaderCount(): int; diff --git a/src/Filesystem/WritableFileInterface.php b/src/Filesystem/WritableFileInterface.php index a4a61376..6ce4474e 100644 --- a/src/Filesystem/WritableFileInterface.php +++ b/src/Filesystem/WritableFileInterface.php @@ -18,5 +18,8 @@ */ interface WritableFileInterface extends FileStreamInterface { + /** + * @param array $fields + */ public function writeLine(array $fields): int; } diff --git a/src/Logger/AbstractProcessor.php b/src/Logger/AbstractProcessor.php index 715167ab..fb7b1e62 100644 --- a/src/Logger/AbstractProcessor.php +++ b/src/Logger/AbstractProcessor.php @@ -47,6 +47,11 @@ public function __invoke(LogRecord $record): LogRecord return $record; } + /** + * @param array $record + * + * @return array + */ protected function normalizeRecordData(array $record): array { $newRecord = []; @@ -57,6 +62,9 @@ protected function normalizeRecordData(array $record): array return $newRecord; } + /** + * @param array $record + */ protected function addProcessInfoToRecord(array &$record): void { $processHistory = $this->processManager->getProcessHistory(); @@ -69,6 +77,9 @@ protected function addProcessInfoToRecord(array &$record): void $this->addToRecord($record, 'process_context', $processHistory->getContext()); } + /** + * @param array $record + */ protected function addTaskInfoToRecord(array &$record): void { $taskConfiguration = $this->processManager->getTaskConfiguration(); @@ -89,6 +100,9 @@ protected function addTaskInfoToRecord(array &$record): void } } + /** + * @param array $record + */ protected function addToRecord(array &$record, string $name, mixed $data): void { $record[$name] = $data; diff --git a/src/Manager/ProcessManager.php b/src/Manager/ProcessManager.php index 231460be..188f6515 100644 --- a/src/Manager/ProcessManager.php +++ b/src/Manager/ProcessManager.php @@ -84,6 +84,8 @@ public function getTaskConfiguration(): ?TaskConfiguration * This method decorates the real execution to add event & error handling * * @see ProcessManager::doExecute + * + * @param array $context */ public function execute(string $processCode, mixed $input = null, array $context = []): mixed { @@ -118,6 +120,8 @@ public function execute(string $processCode, mixed $input = null, array $context /** * Real process execution, with a given input and context. + * + * @param array $context */ protected function doExecute(string $processCode, mixed $input = null, array $context = []): mixed { @@ -463,6 +467,9 @@ protected function finalize(TaskConfiguration $taskConfiguration): void } } + /** + * @param array $context + */ protected function initializeStates( ProcessConfiguration $processConfiguration, array $context = [], diff --git a/src/Model/AbstractConfigurableTask.php b/src/Model/AbstractConfigurableTask.php index 5228cec6..c4eb99ee 100644 --- a/src/Model/AbstractConfigurableTask.php +++ b/src/Model/AbstractConfigurableTask.php @@ -21,6 +21,9 @@ */ abstract class AbstractConfigurableTask implements InitializableTaskInterface, ResetInterface { + /** + * @var array|null + */ protected ?array $options = null; /** @@ -36,6 +39,9 @@ public function reset(): void $this->options = null; } + /** + * @return array|null + */ protected function getOptions(ProcessState $state): ?array { if (null === $this->options) { diff --git a/src/Model/ProcessHistory.php b/src/Model/ProcessHistory.php index 1149c99b..de7c51e5 100644 --- a/src/Model/ProcessHistory.php +++ b/src/Model/ProcessHistory.php @@ -36,6 +36,9 @@ class ProcessHistory implements \Stringable protected string $state = self::STATE_STARTED; + /** + * @param array $context + */ public function __construct( ProcessConfiguration $processConfiguration, protected array $context = [], @@ -64,6 +67,9 @@ public function getProcessCode(): string return $this->processCode; } + /** + * @return array + */ public function getContext(): array { return $this->context; diff --git a/src/Model/ProcessState.php b/src/Model/ProcessState.php index c9a5cef7..13ef03d1 100644 --- a/src/Model/ProcessState.php +++ b/src/Model/ProcessState.php @@ -51,16 +51,25 @@ class ProcessState protected ?\Throwable $exception = null; + /** + * @var array + */ protected array $errorContext = []; protected ?int $returnCode = null; protected bool $skipped; + /** + * @var array|null + */ protected ?array $context = null; protected ?ContextualOptionResolver $contextualOptionResolver = null; + /** + * @var array|null + */ protected ?array $contextualizedOptions = null; protected ?ProcessState $previousState = null; @@ -191,11 +200,17 @@ public function setException(?\Throwable $exception = null): void $this->exception = $exception; } + /** + * @return array + */ public function getErrorContext(): array { return $this->errorContext; } + /** + * @param array $errorContext + */ public function setErrorContext(array $errorContext): void { $this->errorContext = $errorContext; @@ -260,11 +275,17 @@ public function isResolved(): bool return self::STATUS_RESOLVED === $this->status; } + /** + * @return array + */ public function getContext(): array { return $this->context; } + /** + * @param array $context + */ public function setContext(array $context): void { if ($this->context) { @@ -274,6 +295,9 @@ public function setContext(array $context): void $this->context = $context; } + /** + * @return array|null + */ public function getContextualizedOptions(): ?array { if (!$this->contextualizedOptions) { diff --git a/src/Model/SubprocessInstance.php b/src/Model/SubprocessInstance.php index ff49bc70..f52b94f0 100644 --- a/src/Model/SubprocessInstance.php +++ b/src/Model/SubprocessInstance.php @@ -27,6 +27,9 @@ class SubprocessInstance protected string $bufferPath; + /** + * @var array + */ protected array $options; protected string $consolePath; @@ -35,6 +38,10 @@ class SubprocessInstance protected string $logDir; + /** + * @param array $context + * @param array $options + */ public function __construct( KernelInterface $kernel, protected string $processCode, @@ -125,11 +132,17 @@ public function getInput(): ?string return $this->input; } + /** + * @return array + */ public function getOptions(): array { return $this->options; } + /** + * @return array + */ public function getContext(): array { return $this->context; diff --git a/src/Registry/ProcessConfigurationRegistry.php b/src/Registry/ProcessConfigurationRegistry.php index 2c5c9fa4..d22feea6 100644 --- a/src/Registry/ProcessConfigurationRegistry.php +++ b/src/Registry/ProcessConfigurationRegistry.php @@ -29,6 +29,9 @@ class ProcessConfigurationRegistry */ protected array $processConfigurations = []; + /** + * @param array> $rawConfiguration + */ public function __construct( protected array $rawConfiguration, protected string $defaultErrorStrategy, diff --git a/src/Task/AbstractIterableOutputTask.php b/src/Task/AbstractIterableOutputTask.php index e586f062..b756d049 100644 --- a/src/Task/AbstractIterableOutputTask.php +++ b/src/Task/AbstractIterableOutputTask.php @@ -76,12 +76,6 @@ protected function handleIteratorFromInput(ProcessState $state): void $this->iterator = null; } - // This should never be reached - /* @phpstan-ignore-next-line */ - if (null !== $this->iterator) { - throw new \UnexpectedValueException("At this point iterator should have been null, maybe it's a wrong type..."); - } - $this->iterator = $this->initializeIterator($state); } diff --git a/src/Task/AggregateIterableTask.php b/src/Task/AggregateIterableTask.php index 893d2206..bc87bf34 100644 --- a/src/Task/AggregateIterableTask.php +++ b/src/Task/AggregateIterableTask.php @@ -23,6 +23,9 @@ */ class AggregateIterableTask implements BlockingTaskInterface { + /** + * @var list + */ protected array $result = []; public function execute(ProcessState $state): void diff --git a/src/Task/ArrayMergeTask.php b/src/Task/ArrayMergeTask.php index a00e45ae..93a2ebb5 100644 --- a/src/Task/ArrayMergeTask.php +++ b/src/Task/ArrayMergeTask.php @@ -25,6 +25,9 @@ class ArrayMergeTask extends AbstractConfigurableTask implements BlockingTaskInt { protected const MERGE_FUNC = ['array_merge', 'array_merge_recursive', 'array_replace', 'array_replace_recursive']; + /** + * @var array + */ protected array $mergedOutput = []; public function execute(ProcessState $state): void diff --git a/src/Task/ColumnAggregatorTask.php b/src/Task/ColumnAggregatorTask.php index 33f9445f..b3feaf21 100644 --- a/src/Task/ColumnAggregatorTask.php +++ b/src/Task/ColumnAggregatorTask.php @@ -29,6 +29,9 @@ class ColumnAggregatorTask extends AbstractConfigurableTask implements BlockingT { use ConditionTrait; + /** + * @var array + */ protected array $result = []; public function __construct( diff --git a/src/Task/File/Csv/AbstractCsvResourceTask.php b/src/Task/File/Csv/AbstractCsvResourceTask.php index a0ed37b9..a4c8be16 100644 --- a/src/Task/File/Csv/AbstractCsvResourceTask.php +++ b/src/Task/File/Csv/AbstractCsvResourceTask.php @@ -63,5 +63,10 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('headers', ['null', 'array']); } + /** + * @param array $options + * + * @return list|null + */ abstract protected function getHeaders(ProcessState $state, array $options): ?array; } diff --git a/src/Task/File/Csv/CsvReaderTask.php b/src/Task/File/Csv/CsvReaderTask.php index f21d593c..635041f4 100644 --- a/src/Task/File/Csv/CsvReaderTask.php +++ b/src/Task/File/Csv/CsvReaderTask.php @@ -84,6 +84,11 @@ public function next(ProcessState $state): bool return !$endOfFile; } + /** + * @param array $options + * + * @return list|null + */ protected function getHeaders(ProcessState $state, array $options): ?array { return $options['headers']; diff --git a/src/Task/File/Csv/CsvWriterTask.php b/src/Task/File/Csv/CsvWriterTask.php index e87a0931..c0e1a922 100644 --- a/src/Task/File/Csv/CsvWriterTask.php +++ b/src/Task/File/Csv/CsvWriterTask.php @@ -67,6 +67,9 @@ protected function configureOptions(OptionsResolver $resolver): void ); } + /** + * @return array + */ protected function getInput(ProcessState $state): array { $input = $state->getInput(); @@ -84,6 +87,11 @@ protected function getInput(ProcessState $state): array return $input; } + /** + * @param array $options + * + * @return list|null + */ protected function getHeaders(ProcessState $state, array $options): ?array { $headers = $options['headers']; diff --git a/src/Task/File/Csv/InputCsvReaderTask.php b/src/Task/File/Csv/InputCsvReaderTask.php index 2234a263..2781c000 100644 --- a/src/Task/File/Csv/InputCsvReaderTask.php +++ b/src/Task/File/Csv/InputCsvReaderTask.php @@ -21,6 +21,9 @@ */ class InputCsvReaderTask extends CsvReaderTask { + /** + * @return array + */ #[\Override] protected function getOptions(ProcessState $state): array { @@ -45,6 +48,8 @@ protected function configureOptions(OptionsResolver $resolver): void /** * If there is no base_path, then the given path from input should be absolute. + * + * @param array $options */ protected function getFilePath(array $options, string $input): string { diff --git a/src/Task/File/FolderBrowserTask.php b/src/Task/File/FolderBrowserTask.php index 2148fe47..540e2c61 100644 --- a/src/Task/File/FolderBrowserTask.php +++ b/src/Task/File/FolderBrowserTask.php @@ -30,7 +30,7 @@ class FolderBrowserTask extends AbstractConfigurableTask implements IterableTaskInterface { /** - * @var \Iterator|SplFileInfo[]|null + * @var \Iterator|array|null */ protected \Iterator|array|null $files = null; diff --git a/src/Task/File/InputFileReaderTask.php b/src/Task/File/InputFileReaderTask.php index d378a6dd..b2b36178 100644 --- a/src/Task/File/InputFileReaderTask.php +++ b/src/Task/File/InputFileReaderTask.php @@ -21,6 +21,9 @@ */ class InputFileReaderTask extends FileReaderTask { + /** + * @return array + */ #[\Override] protected function getOptions(ProcessState $state): array { diff --git a/src/Task/File/InputFolderBrowserTask.php b/src/Task/File/InputFolderBrowserTask.php index 6a819f01..ae7a98d3 100644 --- a/src/Task/File/InputFolderBrowserTask.php +++ b/src/Task/File/InputFolderBrowserTask.php @@ -61,6 +61,9 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('base_folder_path', ['string']); } + /** + * @return array + */ #[\Override] protected function getOptions(ProcessState $state): array { diff --git a/src/Task/File/InputLineReaderTask.php b/src/Task/File/InputLineReaderTask.php index 73ac0ea2..1737f404 100644 --- a/src/Task/File/InputLineReaderTask.php +++ b/src/Task/File/InputLineReaderTask.php @@ -21,6 +21,9 @@ */ class InputLineReaderTask extends LineReaderTask { + /** + * @return array + */ #[\Override] protected function getOptions(ProcessState $state): array { diff --git a/src/Task/GroupByAggregateIterableTask.php b/src/Task/GroupByAggregateIterableTask.php index b92e2f18..6891add0 100644 --- a/src/Task/GroupByAggregateIterableTask.php +++ b/src/Task/GroupByAggregateIterableTask.php @@ -30,6 +30,9 @@ class GroupByAggregateIterableTask extends AbstractConfigurableTask implements B */ final public const GROUP_BY_OPTION = 'group_by_accessors'; + /** + * @var array + */ protected array $result = []; public function __construct( diff --git a/src/Task/InputAggregatorTask.php b/src/Task/InputAggregatorTask.php index c5b68fa3..12af9859 100644 --- a/src/Task/InputAggregatorTask.php +++ b/src/Task/InputAggregatorTask.php @@ -26,6 +26,9 @@ */ class InputAggregatorTask extends AbstractConfigurableTask { + /** + * @var array + */ protected array $inputs = []; /** @@ -35,7 +38,7 @@ class InputAggregatorTask extends AbstractConfigurableTask public function execute(ProcessState $state): void { $previousState = $state->getPreviousState(); - if (!$previousState || !$previousState->getTaskConfiguration()) { + if (!$previousState instanceof ProcessState) { throw new \UnexpectedValueException('This task cannot be used without a previous task'); } diff --git a/src/Task/InputIteratorTask.php b/src/Task/InputIteratorTask.php index a079626d..4af27f80 100644 --- a/src/Task/InputIteratorTask.php +++ b/src/Task/InputIteratorTask.php @@ -27,7 +27,16 @@ protected function initializeIterator(ProcessState $state): \Iterator return $input; } if ($input instanceof \IteratorAggregate) { - return $input->getIterator(); + $iterator = $input->getIterator(); + if ($iterator instanceof \Iterator) { + return $iterator; + } + + // getIterator() may return any \Traversable, such as another \IteratorAggregate + $iterator = new \IteratorIterator($iterator); + $iterator->rewind(); + + return $iterator; } if (\is_array($input)) { return new \ArrayIterator($input); diff --git a/src/Task/IterableBatchTask.php b/src/Task/IterableBatchTask.php index f841f3f5..692e5666 100644 --- a/src/Task/IterableBatchTask.php +++ b/src/Task/IterableBatchTask.php @@ -26,6 +26,9 @@ */ class IterableBatchTask extends AbstractConfigurableTask implements FlushableTaskInterface, IterableTaskInterface { + /** + * @var \SplQueue|null + */ protected ?\SplQueue $outputQueue = null; protected bool $flushMode = false; diff --git a/src/Task/Process/ProcessLauncherTask.php b/src/Task/Process/ProcessLauncherTask.php index 5f5789b6..692016fa 100644 --- a/src/Task/Process/ProcessLauncherTask.php +++ b/src/Task/Process/ProcessLauncherTask.php @@ -35,6 +35,9 @@ class ProcessLauncherTask extends AbstractConfigurableTask implements FlushableT */ protected array $launchedProcesses = []; + /** + * @var \SplQueue + */ protected \SplQueue $finishedBuffers; protected bool $flushMode = false; @@ -59,7 +62,6 @@ public function execute(ProcessState $state): void $state->setOutput($this->finishedBuffers->dequeue()); // After dequeue, stop flush - /* @phpstan-ignore-next-line */ if ($this->finishedBuffers->isEmpty()) { $this->flushMode = false; } diff --git a/src/Task/RowAggregatorTask.php b/src/Task/RowAggregatorTask.php index 7e5c85be..f999982f 100644 --- a/src/Task/RowAggregatorTask.php +++ b/src/Task/RowAggregatorTask.php @@ -27,6 +27,9 @@ */ class RowAggregatorTask extends AbstractConfigurableTask implements BlockingTaskInterface { + /** + * @var array + */ protected array $result = []; public function __construct( diff --git a/src/Task/SimpleBatchTask.php b/src/Task/SimpleBatchTask.php index 6bdb99bf..8f711c20 100644 --- a/src/Task/SimpleBatchTask.php +++ b/src/Task/SimpleBatchTask.php @@ -23,6 +23,9 @@ */ class SimpleBatchTask extends AbstractConfigurableTask implements FlushableTaskInterface { + /** + * @var list + */ protected array $elements = []; public function flush(ProcessState $state): void diff --git a/src/Transformer/Array/ArrayElementTransformer.php b/src/Transformer/Array/ArrayElementTransformer.php index 933e12a8..093e29d5 100644 --- a/src/Transformer/Array/ArrayElementTransformer.php +++ b/src/Transformer/Array/ArrayElementTransformer.php @@ -21,6 +21,9 @@ */ class ArrayElementTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { return array_values(\array_slice($value, $options['index'], 1))[0]; diff --git a/src/Transformer/Array/ArrayFilterTransformer.php b/src/Transformer/Array/ArrayFilterTransformer.php index a755a985..198d3b1b 100644 --- a/src/Transformer/Array/ArrayFilterTransformer.php +++ b/src/Transformer/Array/ArrayFilterTransformer.php @@ -33,6 +33,8 @@ public function __construct(PropertyAccessorInterface $accessor) } /** + * @param array $options + * * @return array */ public function transform(mixed $value, array $options = []): array diff --git a/src/Transformer/Array/ArrayFirstTransformer.php b/src/Transformer/Array/ArrayFirstTransformer.php index fef817e4..6a8a61fd 100644 --- a/src/Transformer/Array/ArrayFirstTransformer.php +++ b/src/Transformer/Array/ArrayFirstTransformer.php @@ -23,6 +23,8 @@ class ArrayFirstTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. + * + * @param array $options */ public function transform(mixed $value, array $options = []): mixed { diff --git a/src/Transformer/Array/ArrayLastTransformer.php b/src/Transformer/Array/ArrayLastTransformer.php index c2389852..6a3c477f 100644 --- a/src/Transformer/Array/ArrayLastTransformer.php +++ b/src/Transformer/Array/ArrayLastTransformer.php @@ -20,6 +20,9 @@ */ class ArrayLastTransformer implements TransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { return array_values(\array_slice($value, -1))[0]; diff --git a/src/Transformer/Array/ArrayMapTransformer.php b/src/Transformer/Array/ArrayMapTransformer.php index 1263a9f7..e878021d 100644 --- a/src/Transformer/Array/ArrayMapTransformer.php +++ b/src/Transformer/Array/ArrayMapTransformer.php @@ -33,6 +33,10 @@ public function __construct(TransformerRegistry $transformerRegistry) /** * Must return the transformed $value. + * + * @param array $options + * + * @return array */ public function transform(mixed $value, array $options = []): array { diff --git a/src/Transformer/Array/ArrayUnsetTransformer.php b/src/Transformer/Array/ArrayUnsetTransformer.php index 0e2bcf29..51d6b400 100644 --- a/src/Transformer/Array/ArrayUnsetTransformer.php +++ b/src/Transformer/Array/ArrayUnsetTransformer.php @@ -21,6 +21,9 @@ */ class ArrayUnsetTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (!\is_array($value)) { diff --git a/src/Transformer/CachedTransformer.php b/src/Transformer/CachedTransformer.php index 70e7bf46..9cb226e7 100644 --- a/src/Transformer/CachedTransformer.php +++ b/src/Transformer/CachedTransformer.php @@ -62,6 +62,9 @@ static function (Options $options, $value) { $this->configureTransformersOptions($resolver, 'key_transformers'); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { $cacheKey = $this->generateCacheKey($options['cache_key'], $value, $options); @@ -104,6 +107,9 @@ public function getCode(): string return 'cached'; } + /** + * @param array $options + */ protected function generateCacheKey(string $cacheKeyRoot, mixed $value, array $options): bool|string { $value = $this->applyTransformers($options['key_transformers'], $value); diff --git a/src/Transformer/CallbackTransformer.php b/src/Transformer/CallbackTransformer.php index 88e1f275..a18e6ddd 100644 --- a/src/Transformer/CallbackTransformer.php +++ b/src/Transformer/CallbackTransformer.php @@ -24,6 +24,8 @@ class CallbackTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. + * + * @param array $options */ public function transform(mixed $value, array $options = []): mixed { diff --git a/src/Transformer/CastTransformer.php b/src/Transformer/CastTransformer.php index 559af464..7778ec04 100644 --- a/src/Transformer/CastTransformer.php +++ b/src/Transformer/CastTransformer.php @@ -20,6 +20,9 @@ */ class CastTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { settype($value, $options['type']); diff --git a/src/Transformer/ConditionTrait.php b/src/Transformer/ConditionTrait.php index 076cb0e3..9e282e8e 100644 --- a/src/Transformer/ConditionTrait.php +++ b/src/Transformer/ConditionTrait.php @@ -26,6 +26,8 @@ trait ConditionTrait /** * Test the input with the given set of conditions * True by default. + * + * @param array $conditions */ protected function checkCondition(mixed $input, array $conditions): bool { diff --git a/src/Transformer/ConstantTransformer.php b/src/Transformer/ConstantTransformer.php index ec0ae7ca..7f3c34d2 100644 --- a/src/Transformer/ConstantTransformer.php +++ b/src/Transformer/ConstantTransformer.php @@ -28,6 +28,8 @@ public function configureOptions(OptionsResolver $resolver): void /** * Must return the transformed $value. + * + * @param array $options */ public function transform(mixed $value, array $options = []): mixed { diff --git a/src/Transformer/ConvertValueTransformer.php b/src/Transformer/ConvertValueTransformer.php index e9a7775b..84579531 100644 --- a/src/Transformer/ConvertValueTransformer.php +++ b/src/Transformer/ConvertValueTransformer.php @@ -22,6 +22,8 @@ class ConvertValueTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. + * + * @param array $options */ public function transform(mixed $value, array $options = []): mixed { diff --git a/src/Transformer/Date/DateFormatTransformer.php b/src/Transformer/Date/DateFormatTransformer.php index ba95e3d0..bdd5cecc 100644 --- a/src/Transformer/Date/DateFormatTransformer.php +++ b/src/Transformer/Date/DateFormatTransformer.php @@ -26,6 +26,9 @@ */ class DateFormatTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (!$value) { diff --git a/src/Transformer/Date/DateParserTransformer.php b/src/Transformer/Date/DateParserTransformer.php index 526d0afd..cb5ade3f 100644 --- a/src/Transformer/Date/DateParserTransformer.php +++ b/src/Transformer/Date/DateParserTransformer.php @@ -26,6 +26,9 @@ */ class DateParserTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (!$value || $value instanceof \DateTime) { diff --git a/src/Transformer/DebugTransformer.php b/src/Transformer/DebugTransformer.php index 16f11174..2d528b09 100644 --- a/src/Transformer/DebugTransformer.php +++ b/src/Transformer/DebugTransformer.php @@ -20,6 +20,9 @@ */ class DebugTransformer implements TransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (class_exists(VarDumper::class)) { diff --git a/src/Transformer/DefaultTransformer.php b/src/Transformer/DefaultTransformer.php index 83628fe9..f83effd0 100644 --- a/src/Transformer/DefaultTransformer.php +++ b/src/Transformer/DefaultTransformer.php @@ -25,6 +25,9 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setRequired('value'); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (!$value) { diff --git a/src/Transformer/EvaluatorTransformer.php b/src/Transformer/EvaluatorTransformer.php index 33ceba2b..a0ecdeb4 100644 --- a/src/Transformer/EvaluatorTransformer.php +++ b/src/Transformer/EvaluatorTransformer.php @@ -47,6 +47,9 @@ function (Options $options, $expression) { ); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { return $this->language->evaluate($options['expression'], $value); diff --git a/src/Transformer/ExpressionLanguageMapTransformer.php b/src/Transformer/ExpressionLanguageMapTransformer.php index 186231e7..5ea27bff 100644 --- a/src/Transformer/ExpressionLanguageMapTransformer.php +++ b/src/Transformer/ExpressionLanguageMapTransformer.php @@ -64,6 +64,9 @@ function (Options $options, $values): array { ); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { $input = [ diff --git a/src/Transformer/GenericTransformer.php b/src/Transformer/GenericTransformer.php index bf53d955..11e4d29a 100644 --- a/src/Transformer/GenericTransformer.php +++ b/src/Transformer/GenericTransformer.php @@ -27,8 +27,14 @@ class GenericTransformer implements ConfigurableTransformerInterface protected ?string $transformerCode = null; + /** + * @var array|null + */ protected ?array $preconfiguredTransformerOptions = null; + /** + * @var array|null + */ protected ?array $contextualOptions = null; public function __construct( @@ -40,6 +46,8 @@ public function __construct( /** * Register the generic options, and load the transformer list. + * + * @param array $options */ public function initialize(string $code, array $options = []): void { @@ -102,6 +110,9 @@ public function configureOptions(OptionsResolver $resolver): void }); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { return $this->applyTransformers($options['transformers'], $value); @@ -114,6 +125,11 @@ public function getCode(): string /** * Get the real transformer from contextual options + generic definitions. + * + * @param Options> $options + * @param array $transformerOptions + * + * @return array */ public function normalizeTransformerOptions(Options $options, array $transformerOptions): array { diff --git a/src/Transformer/MappingTransformer.php b/src/Transformer/MappingTransformer.php index ff8b0001..2668c403 100644 --- a/src/Transformer/MappingTransformer.php +++ b/src/Transformer/MappingTransformer.php @@ -37,6 +37,9 @@ public function __construct( $this->transformerRegistry = $transformerRegistry; } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (!empty($options['initial_value']) && $options['keep_input']) { @@ -142,7 +145,7 @@ function (Options $options, $value): array { $resolvedMapping = []; $mappingResolver = new OptionsResolver(); $this->configureMappingOptions($mappingResolver); - /** @var array $value */ + /** @var array|null> $value */ foreach ($value as $property => $mappingConfig) { $resolvedMapping[$property] = $mappingResolver->resolve($mappingConfig ?? []); } diff --git a/src/Transformer/MultiReplaceTransformer.php b/src/Transformer/MultiReplaceTransformer.php index 5ff4b927..849baf12 100644 --- a/src/Transformer/MultiReplaceTransformer.php +++ b/src/Transformer/MultiReplaceTransformer.php @@ -24,6 +24,9 @@ */ class MultiReplaceTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { foreach ($options['replace_mapping'] as $pattern => $replacement) { diff --git a/src/Transformer/Object/InstantiateTransformer.php b/src/Transformer/Object/InstantiateTransformer.php index 41993a58..902ce037 100644 --- a/src/Transformer/Object/InstantiateTransformer.php +++ b/src/Transformer/Object/InstantiateTransformer.php @@ -21,6 +21,9 @@ */ class InstantiateTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (!\is_array($value)) { diff --git a/src/Transformer/Object/PropertyAccessorTransformer.php b/src/Transformer/Object/PropertyAccessorTransformer.php index 90e59b29..84497815 100644 --- a/src/Transformer/Object/PropertyAccessorTransformer.php +++ b/src/Transformer/Object/PropertyAccessorTransformer.php @@ -27,6 +27,9 @@ public function __construct( ) { } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (null === $value && $options['ignore_null']) { diff --git a/src/Transformer/Object/RecursivePropertySetterTransformer.php b/src/Transformer/Object/RecursivePropertySetterTransformer.php index 9bf7c0d4..4a924666 100644 --- a/src/Transformer/Object/RecursivePropertySetterTransformer.php +++ b/src/Transformer/Object/RecursivePropertySetterTransformer.php @@ -30,6 +30,9 @@ public function __construct( ) { } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (null === $value && $options['ignore_null']) { diff --git a/src/Transformer/PregFilterTransformer.php b/src/Transformer/PregFilterTransformer.php index 7b046878..9aa3aabf 100644 --- a/src/Transformer/PregFilterTransformer.php +++ b/src/Transformer/PregFilterTransformer.php @@ -19,6 +19,11 @@ class PregFilterTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + * + * @return array|string|null + */ public function transform(mixed $value, array $options = []): array|string|null { $pattern = $options['pattern']; diff --git a/src/Transformer/RulesTransformer.php b/src/Transformer/RulesTransformer.php index c9e5fbbd..048d4c66 100644 --- a/src/Transformer/RulesTransformer.php +++ b/src/Transformer/RulesTransformer.php @@ -33,6 +33,9 @@ public function __construct( $this->transformerRegistry = $transformerRegistry; } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { foreach ($options['rules_set'] as $rule) { @@ -92,6 +95,8 @@ public function configureOptions(OptionsResolver $resolver): void /** * Configure options for one "rule" block. + * + * @param array|null $expressionVariables */ public function configureRuleOptions(OptionsResolver $resolver, ?array $expressionVariables = null): void { @@ -127,6 +132,8 @@ public function configureRuleOptions(OptionsResolver $resolver, ?array $expressi /** * Test if a value match a rule. + * + * @param array $rule */ protected function matchRule(mixed $value, array $rule, bool $useValueAsVariable): bool { diff --git a/src/Transformer/Serialization/DenormalizeTransformer.php b/src/Transformer/Serialization/DenormalizeTransformer.php index f939b074..3e6526a6 100644 --- a/src/Transformer/Serialization/DenormalizeTransformer.php +++ b/src/Transformer/Serialization/DenormalizeTransformer.php @@ -39,6 +39,9 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('context', ['array']); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { return $this->denormalizer->denormalize($value, $options['class'], $options['format'], $options['context']); diff --git a/src/Transformer/Serialization/NormalizeTransformer.php b/src/Transformer/Serialization/NormalizeTransformer.php index f23293a6..b71e038e 100644 --- a/src/Transformer/Serialization/NormalizeTransformer.php +++ b/src/Transformer/Serialization/NormalizeTransformer.php @@ -37,6 +37,9 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('context', ['array']); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { return $this->normalizer->normalize($value, $options['format'], $options['context']); diff --git a/src/Transformer/String/ExplodeTransformer.php b/src/Transformer/String/ExplodeTransformer.php index 32542a43..fd2e4be6 100644 --- a/src/Transformer/String/ExplodeTransformer.php +++ b/src/Transformer/String/ExplodeTransformer.php @@ -21,6 +21,11 @@ */ class ExplodeTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + * + * @return list + */ public function transform(mixed $value, array $options = []): array { if (null === $value || '' === $value) { diff --git a/src/Transformer/String/HashTransformer.php b/src/Transformer/String/HashTransformer.php index 2dc58b11..b8422a41 100644 --- a/src/Transformer/String/HashTransformer.php +++ b/src/Transformer/String/HashTransformer.php @@ -32,6 +32,9 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('raw_output', 'bool'); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): string { return hash((string) $options['algo'], (string) $value, $options['raw_output']); diff --git a/src/Transformer/String/ImplodeTransformer.php b/src/Transformer/String/ImplodeTransformer.php index 7257ac13..d60e7ac0 100644 --- a/src/Transformer/String/ImplodeTransformer.php +++ b/src/Transformer/String/ImplodeTransformer.php @@ -27,6 +27,9 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('separator', 'string'); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): string { if (!\is_array($value)) { diff --git a/src/Transformer/String/PregMatchTransformer.php b/src/Transformer/String/PregMatchTransformer.php index 143ba36b..38899f0e 100644 --- a/src/Transformer/String/PregMatchTransformer.php +++ b/src/Transformer/String/PregMatchTransformer.php @@ -21,6 +21,11 @@ */ class PregMatchTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + * + * @return array|null + */ public function transform(mixed $value, array $options = []): ?array { if (null === $value || '' === $value) { diff --git a/src/Transformer/String/SlugifyTransformer.php b/src/Transformer/String/SlugifyTransformer.php index 7b682905..f3c02275 100644 --- a/src/Transformer/String/SlugifyTransformer.php +++ b/src/Transformer/String/SlugifyTransformer.php @@ -23,6 +23,9 @@ */ class SlugifyTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): string { /** @var \Transliterator $transliterator */ diff --git a/src/Transformer/String/SprintfTransformer.php b/src/Transformer/String/SprintfTransformer.php index a3263615..e87804ee 100644 --- a/src/Transformer/String/SprintfTransformer.php +++ b/src/Transformer/String/SprintfTransformer.php @@ -21,6 +21,9 @@ */ class SprintfTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): string { if (!\is_array($value)) { diff --git a/src/Transformer/String/TrimTransformer.php b/src/Transformer/String/TrimTransformer.php index e2d97819..ad305cf9 100644 --- a/src/Transformer/String/TrimTransformer.php +++ b/src/Transformer/String/TrimTransformer.php @@ -21,6 +21,9 @@ */ class TrimTransformer implements ConfigurableTransformerInterface { + /** + * @param array $options + */ public function transform(mixed $value, ?array $options = []): ?string { if (null === $options || [] === $options) { diff --git a/src/Transformer/TransformerInterface.php b/src/Transformer/TransformerInterface.php index 7cf44d54..8a61e7fe 100644 --- a/src/Transformer/TransformerInterface.php +++ b/src/Transformer/TransformerInterface.php @@ -20,6 +20,8 @@ interface TransformerInterface { /** * Must return the transformed $value. + * + * @param array $options */ public function transform(mixed $value, array $options = []): mixed; diff --git a/src/Transformer/TransformerTrait.php b/src/Transformer/TransformerTrait.php index e43563e6..34b0a2d8 100644 --- a/src/Transformer/TransformerTrait.php +++ b/src/Transformer/TransformerTrait.php @@ -25,6 +25,11 @@ trait TransformerTrait /** * Transform the list of transformer codes + options into a list of Closure (better performances). + * + * @param Options> $options + * @param array|null> $transformers + * + * @return array */ public function normalizeTransformers(Options $options, array $transformers): array { @@ -49,6 +54,9 @@ public function normalizeTransformers(Options $options, array $transformers): ar return $transformerClosures; } + /** + * @param array $transformers + */ protected function applyTransformers(array $transformers, mixed $value): mixed { // Quick return for better perfs @@ -104,6 +112,8 @@ protected function configureTransformersOptions( /** * Check the options to always return an array, or fail on unexpected values. + * + * @return array */ private function checkTransformerOptions(mixed $transformerOptions, string $transformerCode): array { diff --git a/src/Transformer/TypeSetterTransformer.php b/src/Transformer/TypeSetterTransformer.php index 606c62ff..35133e02 100644 --- a/src/Transformer/TypeSetterTransformer.php +++ b/src/Transformer/TypeSetterTransformer.php @@ -27,6 +27,9 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('type', 'string'); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { settype($value, $options['type']); diff --git a/src/Transformer/UnsetTransformer.php b/src/Transformer/UnsetTransformer.php index 112f4ad0..5b6caf76 100644 --- a/src/Transformer/UnsetTransformer.php +++ b/src/Transformer/UnsetTransformer.php @@ -28,6 +28,11 @@ public function __construct(PropertyAccessorInterface $accessor) $this->accessor = $accessor; } + /** + * @param array $options + * + * @return array + */ public function transform(mixed $value, array $options = []): array { if (!\is_array($value)) { diff --git a/src/Transformer/WrapperTransformer.php b/src/Transformer/WrapperTransformer.php index 297e7253..a3cd0b8d 100644 --- a/src/Transformer/WrapperTransformer.php +++ b/src/Transformer/WrapperTransformer.php @@ -19,6 +19,10 @@ class WrapperTransformer implements ConfigurableTransformerInterface { /** * Must return the transformed $value. + * + * @param array $options + * + * @return array */ public function transform(mixed $value, array $options = []): array { diff --git a/src/Transformer/Xml/XpathEvaluatorTransformer.php b/src/Transformer/Xml/XpathEvaluatorTransformer.php index 32c650c4..87be9f8d 100644 --- a/src/Transformer/Xml/XpathEvaluatorTransformer.php +++ b/src/Transformer/Xml/XpathEvaluatorTransformer.php @@ -64,6 +64,8 @@ public function configureOptions(OptionsResolver $resolver): void /** * Configure options about how to handle xpath query results. * Available at root and subquery level. + * + * @param Options>|null $parentOptions */ public function configureQueryOptions(OptionsResolver $resolver, ?Options $parentOptions = null): void { @@ -77,6 +79,9 @@ public function configureQueryOptions(OptionsResolver $resolver, ?Options $paren $resolver->setAllowedTypes('unwrap_value', 'bool'); } + /** + * @param array $options + */ public function transform(mixed $value, array $options = []): mixed { if (!$value instanceof \DOMNode) { @@ -108,6 +113,9 @@ public function buildXpath(\DOMNode $node): \DOMXPath return new \DOMXPath($doc); } + /** + * @param array $options + */ public function query(\DOMXPath $xpath, string $query, \DOMNode $node, array $options): mixed { $nodeList = $xpath->query($query, $node); diff --git a/src/Validator/ConstraintLoader.php b/src/Validator/ConstraintLoader.php index e2adab9b..b71c32ed 100644 --- a/src/Validator/ConstraintLoader.php +++ b/src/Validator/ConstraintLoader.php @@ -27,6 +27,10 @@ public function loadClassMetadata(ClassMetadata $metadata): bool * Build constraints from textual data. * * @see \Symfony\Component\Validator\Mapping\Loader\YamlFileLoader::parseNodes + * + * @param array $nodes + * + * @return array */ public function buildConstraints(array $nodes): array { diff --git a/tests/Task/AbstractIterableOutputTaskTest.php b/tests/Task/AbstractIterableOutputTaskTest.php index 583d217d..83be8110 100644 --- a/tests/Task/AbstractIterableOutputTaskTest.php +++ b/tests/Task/AbstractIterableOutputTaskTest.php @@ -102,6 +102,9 @@ public function testSplitJoinLineWithoutSplitColumnIsSkipped(): void self::assertSame([], $state->getErrorContext()); } + /** + * @param array $options + */ private function createState(array $options, mixed $input = null): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/ArrayMergeTaskTest.php b/tests/Task/ArrayMergeTaskTest.php index e1f251c9..ba54191e 100644 --- a/tests/Task/ArrayMergeTaskTest.php +++ b/tests/Task/ArrayMergeTaskTest.php @@ -67,7 +67,9 @@ public static function mergeProvider(): iterable } /** - * @param list> $inputs + * @param array $options + * @param list> $inputs + * @param array $expected */ #[DataProvider('mergeProvider')] public function testInputsAreMergedWithMergeFunction(array $options, array $inputs, array $expected): void @@ -140,6 +142,9 @@ public function testInvalidMergeFunctionIsRejected(mixed $mergeFunction): void $task->initialize($state); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/ColumnAggregatorTaskTest.php b/tests/Task/ColumnAggregatorTaskTest.php index cbbb03de..897d86bb 100644 --- a/tests/Task/ColumnAggregatorTaskTest.php +++ b/tests/Task/ColumnAggregatorTaskTest.php @@ -67,6 +67,8 @@ public function testMissingColumnThrows(): void /** * @param list> $inputs + * @param array $options + * @param array $extraOptions */ private function aggregate(array $options, array $inputs, array $extraOptions = []): mixed { @@ -86,6 +88,9 @@ private function aggregate(array $options, array $inputs, array $extraOptions = return $state->getOutput(); } + /** + * @param array $options + */ private function createState(string $class, array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/ConstantIterableOutputTaskTest.php b/tests/Task/ConstantIterableOutputTaskTest.php index 04697d9a..9d4ee45d 100644 --- a/tests/Task/ConstantIterableOutputTaskTest.php +++ b/tests/Task/ConstantIterableOutputTaskTest.php @@ -130,6 +130,9 @@ private function iterate(ConstantIterableOutputTask $task, ProcessState $state): return $outputs; } + /** + * @param array $options + */ private function createState(array $options, mixed $input = null): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/ConstantOutputTaskTest.php b/tests/Task/ConstantOutputTaskTest.php index 4b29355d..4fa809e7 100644 --- a/tests/Task/ConstantOutputTaskTest.php +++ b/tests/Task/ConstantOutputTaskTest.php @@ -92,6 +92,10 @@ public function testMissingOutputOptionFailsAtInitialization(): void $task->initialize($state); } + /** + * @param array $context + * @param array $options + */ private function createState(array $options, mixed $input = null, array $context = []): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/Event/EventDispatcherTaskTest.php b/tests/Task/Event/EventDispatcherTaskTest.php index f0882f84..f72ee729 100644 --- a/tests/Task/Event/EventDispatcherTaskTest.php +++ b/tests/Task/Event/EventDispatcherTaskTest.php @@ -110,6 +110,9 @@ private function createDispatcher(array $eventNames): EventDispatcher return $dispatcher; } + /** + * @param array $options + */ private function execute(EventDispatcher $dispatcher, array $options, mixed $input = null): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/Csv/CsvReaderTaskTest.php b/tests/Task/File/Csv/CsvReaderTaskTest.php index b1bb5a42..b1a612fa 100644 --- a/tests/Task/File/Csv/CsvReaderTaskTest.php +++ b/tests/Task/File/Csv/CsvReaderTaskTest.php @@ -117,6 +117,9 @@ private function iterate(CsvReaderTask $task, ProcessState $state, mixed $input return $outputs; } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/Csv/CsvWriterTaskTest.php b/tests/Task/File/Csv/CsvWriterTaskTest.php index 2059c265..11d02383 100644 --- a/tests/Task/File/Csv/CsvWriterTaskTest.php +++ b/tests/Task/File/Csv/CsvWriterTaskTest.php @@ -272,6 +272,9 @@ private function write(CsvWriterTask $task, ProcessState $state, array $inputs): $task->finalize($state); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/FileMoverTaskTest.php b/tests/Task/File/FileMoverTaskTest.php index 11e53e18..759e3df2 100644 --- a/tests/Task/File/FileMoverTaskTest.php +++ b/tests/Task/File/FileMoverTaskTest.php @@ -198,6 +198,9 @@ public function testThrowsOnInvalidOptions(array $options): void $this->execute($options, $this->tmpDir.'/src/file.csv'); } + /** + * @param array $options + */ private function execute(array $options, mixed $input): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/FileReaderTaskTest.php b/tests/Task/File/FileReaderTaskTest.php index fc85b339..c9601222 100644 --- a/tests/Task/File/FileReaderTaskTest.php +++ b/tests/Task/File/FileReaderTaskTest.php @@ -109,6 +109,9 @@ public function testThrowsOnInvalidFilenameOptionType(): void $this->execute(['filename' => 42]); } + /** + * @param array $options + */ private function execute(array $options, mixed $input = null): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/FileWriterTaskTest.php b/tests/Task/File/FileWriterTaskTest.php index 7d22ecc7..f3cd312a 100644 --- a/tests/Task/File/FileWriterTaskTest.php +++ b/tests/Task/File/FileWriterTaskTest.php @@ -112,6 +112,9 @@ private function write(FileWriterTask $task, ProcessState $state, mixed $input): $task->execute($state); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/FolderBrowserTaskTest.php b/tests/Task/File/FolderBrowserTaskTest.php index fc839f15..0c3cee5a 100644 --- a/tests/Task/File/FolderBrowserTaskTest.php +++ b/tests/Task/File/FolderBrowserTaskTest.php @@ -129,6 +129,9 @@ private function iterate(FolderBrowserTask $task, ProcessState $state, mixed $in return $outputs; } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/InputFileReaderTaskTest.php b/tests/Task/File/InputFileReaderTaskTest.php index bb4b8600..96551daf 100644 --- a/tests/Task/File/InputFileReaderTaskTest.php +++ b/tests/Task/File/InputFileReaderTaskTest.php @@ -125,6 +125,9 @@ private function read(InputFileReaderTask $task, ProcessState $state, mixed $inp return $state->getOutput(); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/JsonStream/JsonStreamReaderTaskTest.php b/tests/Task/File/JsonStream/JsonStreamReaderTaskTest.php index 7ee3658d..c1660510 100644 --- a/tests/Task/File/JsonStream/JsonStreamReaderTaskTest.php +++ b/tests/Task/File/JsonStream/JsonStreamReaderTaskTest.php @@ -239,6 +239,9 @@ private function createFile(string $content, string $name = 'data.jsonl'): strin return $path; } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/LineReaderTaskTest.php b/tests/Task/File/LineReaderTaskTest.php index df1f0752..d84de8a0 100644 --- a/tests/Task/File/LineReaderTaskTest.php +++ b/tests/Task/File/LineReaderTaskTest.php @@ -100,6 +100,9 @@ private function iterate(LineReaderTask $task, ProcessState $state, mixed $input return $outputs; } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/Xml/XmlReaderTaskTest.php b/tests/Task/File/Xml/XmlReaderTaskTest.php index ca6689a6..51bc77a3 100644 --- a/tests/Task/File/Xml/XmlReaderTaskTest.php +++ b/tests/Task/File/Xml/XmlReaderTaskTest.php @@ -147,6 +147,9 @@ public function testModeMustBeAString(): void $this->execute(['file_path' => $this->tmpDir.'/file.xml', 'mode' => true]); } + /** + * @param array $options + */ private function execute(array $options, mixed $input = null): ProcessState { $task = $this->createTask(); @@ -174,6 +177,9 @@ public function log($level, string|\Stringable $message, array $context = []): v }); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/Xml/XmlWriterTaskTest.php b/tests/Task/File/Xml/XmlWriterTaskTest.php index d91f3212..218c7bed 100644 --- a/tests/Task/File/Xml/XmlWriterTaskTest.php +++ b/tests/Task/File/Xml/XmlWriterTaskTest.php @@ -166,6 +166,9 @@ private function createDocument(string $xml): \DOMDocument return $dom; } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/Yaml/YamlReaderTaskTest.php b/tests/Task/File/Yaml/YamlReaderTaskTest.php index 52a509e1..f3e5627b 100644 --- a/tests/Task/File/Yaml/YamlReaderTaskTest.php +++ b/tests/Task/File/Yaml/YamlReaderTaskTest.php @@ -207,6 +207,9 @@ private function iterate(YamlReaderTask $task, ProcessState $state, mixed $input return [$outputs, $keys]; } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/File/Yaml/YamlWriterTaskTest.php b/tests/Task/File/Yaml/YamlWriterTaskTest.php index 3f2ea99c..951dc001 100644 --- a/tests/Task/File/Yaml/YamlWriterTaskTest.php +++ b/tests/Task/File/Yaml/YamlWriterTaskTest.php @@ -135,6 +135,9 @@ public function testInvalidOptionsThrow(array $options): void (new YamlWriterTask())->initialize($this->createState($options)); } + /** + * @param array $options + */ private function execute(array $options, mixed $input): ProcessState { $task = new YamlWriterTask(); @@ -146,6 +149,9 @@ private function execute(array $options, mixed $input): ProcessState return $state; } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/FilterTaskTest.php b/tests/Task/FilterTaskTest.php index 63d20541..761df166 100644 --- a/tests/Task/FilterTaskTest.php +++ b/tests/Task/FilterTaskTest.php @@ -74,7 +74,8 @@ public static function filterProvider(): iterable } /** - * @param list $expectedKept + * @param array $options + * @param list $expectedKept */ #[DataProvider('filterProvider')] public function testInputsAreFiltered(array $options, array $expectedKept): void @@ -138,6 +139,9 @@ public static function scalarProvider(): iterable yield 'other path on scalar is empty' => [['not_empty' => ['[key]' => null]], 'foo', true]; } + /** + * @param array $options + */ #[DataProvider('scalarProvider')] public function testScalarInput(array $options, mixed $input, bool $expectedSkipped): void { @@ -156,6 +160,9 @@ public function testUnknownConditionIsRejected(): void $this->execute(['equals' => []], []); } + /** + * @param array $options + */ private function execute(array $options, mixed $input): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/GroupByAggregateIterableTaskTest.php b/tests/Task/GroupByAggregateIterableTaskTest.php index 518d2292..166d5a17 100644 --- a/tests/Task/GroupByAggregateIterableTaskTest.php +++ b/tests/Task/GroupByAggregateIterableTaskTest.php @@ -130,6 +130,9 @@ private function createTask(mixed $groupBy): array return [$task, $state]; } + /** + * @param list $inputs + */ private function aggregate(GroupByAggregateIterableTask $task, ProcessState $state, array $inputs): mixed { foreach ($inputs as $input) { diff --git a/tests/Task/InputAggregatorTaskTest.php b/tests/Task/InputAggregatorTaskTest.php index 4ef28066..b5a39b40 100644 --- a/tests/Task/InputAggregatorTaskTest.php +++ b/tests/Task/InputAggregatorTaskTest.php @@ -161,6 +161,9 @@ public static function invalidOptionsProvider(): iterable yield 'keep_inputs not an array' => [['input_codes' => [], 'keep_inputs' => 'a']]; } + /** + * @param array $options + */ #[DataProvider('invalidOptionsProvider')] public function testInvalidOptionsAreRejected(array $options): void { @@ -171,6 +174,9 @@ public function testInvalidOptionsAreRejected(array $options): void $task->initialize($this->createState($options)); } + /** + * @param array $options + */ private function receive(InputAggregatorTask $task, array $options, string $previousTaskCode, mixed $input): ProcessState { $previousState = $this->createState([], $previousTaskCode); @@ -184,6 +190,9 @@ private function receive(InputAggregatorTask $task, array $options, string $prev return $state; } + /** + * @param array $options + */ private function createState(array $options, string $code = 'aggregate'): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/InputIteratorTaskTest.php b/tests/Task/InputIteratorTaskTest.php index e6af3bf2..b6b4750e 100644 --- a/tests/Task/InputIteratorTaskTest.php +++ b/tests/Task/InputIteratorTaskTest.php @@ -43,6 +43,23 @@ public static function iterableInputProvider(): iterable yield 'associative array' => [['a' => 1, 'b' => 2, 'c' => 3]]; yield 'iterator' => [new \ArrayIterator(['a' => 1, 'b' => 2, 'c' => 3])]; yield 'iterator aggregate' => [new \ArrayObject([1, 2, 3])]; + yield 'generator aggregate' => [ + new class implements \IteratorAggregate { + public function getIterator(): \Generator + { + yield from [1, 2, 3]; + } + }, + ]; + // getIterator() may return any \Traversable, such as another \IteratorAggregate + yield 'nested iterator aggregate' => [ + new class implements \IteratorAggregate { + public function getIterator(): \Traversable + { + return new \ArrayObject([1, 2, 3]); + } + }, + ]; } #[DataProvider('iterableInputProvider')] @@ -114,6 +131,9 @@ public function testNonIterableInputThrows(mixed $input): void $task->execute($state); } + /** + * @return list + */ private function iterate(InputIteratorTask $task, ProcessState $state, mixed $input): array { $outputs = []; diff --git a/tests/Task/IterableBatchTaskTest.php b/tests/Task/IterableBatchTaskTest.php index debf563e..8010d97b 100644 --- a/tests/Task/IterableBatchTaskTest.php +++ b/tests/Task/IterableBatchTaskTest.php @@ -53,6 +53,8 @@ public function testNullBatchCountOnlyOutputsOnFlush(): void } /** + * @param array $options + * * @return array{IterableBatchTask, ProcessState} */ private function createTask(array $options): array @@ -99,6 +101,9 @@ private function flush(IterableBatchTask $task, ProcessState $state): array return $outputs; } + /** + * @param array $options + */ private function createState(string $class, array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/Process/CommandRunnerTaskTest.php b/tests/Task/Process/CommandRunnerTaskTest.php index 30d047cf..b222c8b7 100644 --- a/tests/Task/Process/CommandRunnerTaskTest.php +++ b/tests/Task/Process/CommandRunnerTaskTest.php @@ -114,6 +114,9 @@ private function createTask(): CommandRunnerTask return new CommandRunnerTask($kernel); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/Process/ProcessLauncherTaskTest.php b/tests/Task/Process/ProcessLauncherTaskTest.php index 76fba37b..1d9ec9c0 100644 --- a/tests/Task/Process/ProcessLauncherTaskTest.php +++ b/tests/Task/Process/ProcessLauncherTaskTest.php @@ -75,6 +75,9 @@ private function createTask(): ProcessLauncherTask return new ProcessLauncherTask(new NullLogger(), $registry, $this->createStub(KernelInterface::class)); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/PropertySetterTaskTest.php b/tests/Task/PropertySetterTaskTest.php index d428a645..42fe0eb5 100644 --- a/tests/Task/PropertySetterTaskTest.php +++ b/tests/Task/PropertySetterTaskTest.php @@ -77,6 +77,9 @@ public function testScalarInputFailureKeepsErrorContext(): void self::assertNull($state->getOutput()); } + /** + * @param array $values + */ private function execute(array $values, mixed $input): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/Reporting/AdvancedStatCounterTaskTest.php b/tests/Task/Reporting/AdvancedStatCounterTaskTest.php index c0a06176..c20e434b 100644 --- a/tests/Task/Reporting/AdvancedStatCounterTaskTest.php +++ b/tests/Task/Reporting/AdvancedStatCounterTaskTest.php @@ -96,6 +96,9 @@ public function log($level, string|\Stringable $message, array $context = []): v return [$logger->messages, $outputs]; } + /** + * @param array $options + */ private function createState(string $class, array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/RowAggregatorTaskTest.php b/tests/Task/RowAggregatorTaskTest.php index cefdd93b..a19f4edb 100644 --- a/tests/Task/RowAggregatorTaskTest.php +++ b/tests/Task/RowAggregatorTaskTest.php @@ -118,6 +118,7 @@ public static function invalidOptionsProvider(): iterable } /** + * @param array $options * @param class-string<\Throwable> $exception */ #[DataProvider('invalidOptionsProvider')] @@ -130,6 +131,9 @@ public function testInvalidOptionsAreRejected(array $options, string $exception) $task->initialize($this->createState($options)); } + /** + * @param array $options + */ private function createState(array $options): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Task/SplitJoinLineTaskTest.php b/tests/Task/SplitJoinLineTaskTest.php index 3fd958db..bfb21b53 100644 --- a/tests/Task/SplitJoinLineTaskTest.php +++ b/tests/Task/SplitJoinLineTaskTest.php @@ -125,6 +125,7 @@ public static function invalidOptionsProvider(): iterable } /** + * @param array $options * @param class-string<\Throwable> $exception */ #[DataProvider('invalidOptionsProvider')] @@ -136,6 +137,8 @@ public function testInvalidOptionsAreRejected(array $options, string $exception) } /** + * @param array $options + * * @return array{SplitJoinLineTask, ProcessState} */ private function createTask(array $options): array @@ -152,6 +155,9 @@ private function createTask(array $options): array return [$task, $state]; } + /** + * @return list + */ private function iterate(SplitJoinLineTask $task, ProcessState $state, mixed $input): array { $outputs = []; diff --git a/tests/Task/TransformerTaskTest.php b/tests/Task/TransformerTaskTest.php index ac70be48..3b9cd132 100644 --- a/tests/Task/TransformerTaskTest.php +++ b/tests/Task/TransformerTaskTest.php @@ -193,6 +193,9 @@ public function testTransformersOptionMustBeAnArray(): void $this->execute(['transformers' => 'trim'], 'value'); } + /** + * @param array $options + */ private function execute(array $options, mixed $input): ProcessState { $processConfiguration = new ProcessConfiguration('test', []); diff --git a/tests/Transformer/Array/ArrayFilterTransformerTest.php b/tests/Transformer/Array/ArrayFilterTransformerTest.php index 32f5ba52..422f2b04 100644 --- a/tests/Transformer/Array/ArrayFilterTransformerTest.php +++ b/tests/Transformer/Array/ArrayFilterTransformerTest.php @@ -43,6 +43,12 @@ public function testConditionOnArrays(): void self::assertSame([2 => ['other' => 'x']], $this->filter($items, ['empty' => ['[type]' => null]])); } + /** + * @param array $value + * @param array $condition + * + * @return array + */ private function filter(array $value, array $condition): array { $transformer = new ArrayFilterTransformer(PropertyAccess::createPropertyAccessor()); diff --git a/tests/Transformer/Serialization/DenormalizeTransformerTest.php b/tests/Transformer/Serialization/DenormalizeTransformerTest.php index 4b68fba1..e05faa53 100644 --- a/tests/Transformer/Serialization/DenormalizeTransformerTest.php +++ b/tests/Transformer/Serialization/DenormalizeTransformerTest.php @@ -73,6 +73,9 @@ public function testContextIsPassedToTheDenormalizer(): void public function testClassFormatAndContextArePassedToTheDenormalizer(): void { $denormalizer = new class implements DenormalizerInterface { + /** + * @return array + */ public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): array { return ['data' => $data, 'type' => $type, 'format' => $format, 'context' => $context];