Skip to content

v5.2

Choose a tag to compare

@njoubert-cleverage njoubert-cleverage released this 12 Oct 12:00
· 165 commits to main since this release
bf03664

Changes

  • #197 Add missing tests: every Task and Transformer is now covered by unit tests. Remove the obsolete tests.old directory.
  • #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.
  • #143 Improve PHPStan level from 6 to 7, and fix the level 8 errors that do not require a signature change (the remaining ones, due to nullable return types such as AbstractConfigurableTask::getOptions(): ?array, will be fixed in v6.0). Default to a ContextualOptionResolver in ProcessState and to a property accessor in ConditionTrait when none is set.
  • #94 TransformerTrait: the transformers option (TransformerTask, MappingTransformer, ArrayMapTransformer, CachedTransformer, RulesTransformer, generic transformers) also accepts a list, whose items are a transformer code without options (- trim) or a single code: options map (- callback: {...}), to chain the same transformer without # suffix. The map syntax is still supported. Update documentation, add tests.
  • #117 MappingTransformer: writing a target property that is a nested path (e.g. address.city) on an array destination, which silently created an address.city literal key, is deprecated and will throw an \UnexpectedValueException in v6.0. Use [address.city] for a literal key or [address][city] for a nested array; a simple property name (e.g. name) is still added as a key. Update documentation, add tests.
  • #258 Add XmlStreamReaderTask: iterable task reading an XML file element by element with \XMLReader (constant memory), outputting each element named node_name as a \DOMElement in its own \DOMDocument, ready for XpathEvaluatorTransformer. The file path is set in the file_path option or given as input. Add documentation and tests.
  • #259 JsonStreamWriterTask: add a mode option (default wb, e.g. ab to append to an existing JSON Lines file), and release the file on finalize(). Update documentation, add tests.
  • #157 Configure the level of the logs written at the end of each process with the new logs option, globally (clever_age_process.logs) or per process (configurations.<code>.logs): success_level (default info) for Process <code> succeed, and failed_level (default debug) for the new Process <code> failed log, written when a process fails, with or without exception. Update documentation, add tests.

Fixes

  • #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.
  • #143 Fix level 8 edge cases failing with a TypeError or an Error: CsvResource rejects a blank header line and checks ftell(), XpathEvaluatorTransformer throws an explicit \UnexpectedValueException on an invalid query (with the libxml messages), a namespace node to unwrap or a node without document, SlugifyTransformer on a value that cannot be transliterated, ProcessState::getContext() returns [] until the context is defined, GenericTransformer and TransformerTrait throw a \LogicException when not initialized, IterableBatchTask and JsonStreamReaderTask can be flushed / iterated before their first execution, RegistryCompilerPass checks its configuration, SubprocessInstance checks the PHP executable. Update documentation, add tests.
  • #239 Fix PropertyGetterTask: catch any \Throwable, so that the TypeError of the property accessor on a scalar input is set on the state (with the property error context) and handled according to the task error_strategy instead of escaping it. Update documentation, add tests.
  • #241 Fix CsvWriterTask: a non-array input throws the documented \UnexpectedValueException instead of a TypeError when headers is null, and the CSV tasks release their file on finalize() so that the task can be executed again. Update documentation, add tests.
  • #240 Fix FileMoverTask: with autoincrement, the suffix was computed on the whole path (a dot in a directory name was taken as the extension, making the move fail for a file without extension) and an existing numeric suffix of the file name was replaced (report-2024.csv became report-1.csv). The suffix is now appended to the file name only (report-2024-1.csv, file-1, .env-1). Update documentation, add tests.
  • #243 Fix RecursivePropertySetterTransformer: a \stdClass item without the property was replaced by a copy in the output, so the input object was not modified; the property is now added to the item itself. Update documentation, add tests.
  • #242 Fix InputFileReaderTask: an input that is not a non-empty string (e.g. null) throws an explicit \UnexpectedValueException (No file path given as input) instead of a PHP warning followed by a TypeError. Update documentation, add tests.
  • #244 Fix MappingTransformer: a missing target property of a \stdClass destination (initial_value or keep_input) threw Property '...' is not writable, it is now added when the target is a simple property name (nested paths still throw). Update documentation, add tests.
  • #143 Type the remaining untyped task options: split_character of CsvWriterTask and SplitJoinLineTask must be a string (a wrong type used to fail later with a TypeError), write_headers of CsvWriterTask and log_empty_lines of CsvReaderTask are cast to bool (any value used to be evaluated as a boolean, so it is still accepted). Update documentation, add tests.