Skip to content

Commit 1d202a2

Browse files
Merge pull request #212 from cleverage/201
#201 - Fix minor defects
2 parents 6f61a97 + 7ec614f commit 1d202a2

17 files changed

Lines changed: 189 additions & 27 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Latest
1919
* [#206](https://github.com/cleverage/process-bundle/issues/206) Fix AdvancedStatCounterTask, IterableBatchTask, ConditionTrait and ColumnAggregatorTask edge cases: log the first counted execution with correct counts, accept a `null` `batch_count` (only flush at the end), allow scalar inputs in conditions (`''` path on the whole value), aggregate `null` column values. Update documentation, add tests.
2020
* [#207](https://github.com/cleverage/process-bundle/issues/207) Fix JsonStreamReaderTask / JsonStreamWriterTask: throw an explicit `\UnexpectedValueException` when a line decodes to a scalar, create the missing parent directory when writing. Update documentation, add tests.
2121
* [#208](https://github.com/cleverage/process-bundle/issues/208) Fix FolderBrowserTask, InputFolderBrowserTask, CsvReaderTask and LineReaderTask (and their `Input*` variants): reset the state at the end of the iteration, so that a following input is read from its beginning. Update documentation, add tests.
22+
* [#201](https://github.com/cleverage/process-bundle/issues/201) Fix minor defects: error messages of TransformerTrait, RulesTransformer and ExpressionLanguageMapTransformer, useless `setRequired()` in ImplodeTransformer and SprintfTransformer, stray namespace in TrimTransformer, wrong or missing docblocks. Add tests.
2223

2324
## Deprecated
2425
* [#189](https://github.com/cleverage/process-bundle/issues/189) EventDispatcherTask: when `event_name` is set, listening to `CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent` is deprecated (the event is still dispatched under its class name, with an `E_USER_DEPRECATED` error, if it has listeners). Listen to the configured `event_name` instead: the BC layer will be removed in v6.0.

‎src/Task/ColumnAggregatorTask.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
2323

2424
/**
25-
* @todo @vclavreul describe this task
25+
* For each configured column, collect the input rows that contain this column (and match the optional condition), and
26+
* output all the groups once all previous tasks are resolved.
2627
*/
2728
class ColumnAggregatorTask extends AbstractConfigurableTask implements BlockingTaskInterface
2829
{

‎src/Task/FilterTask.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/**
2323
* Skip inputs under given matching conditions
24-
* - equality is softly checked
24+
* - equality is strictly checked
2525
* - unexisting key is the same as null.
2626
*/
2727
class FilterTask extends AbstractConfigurableTask

‎src/Task/Process/ProcessExecutorTask.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
use Symfony\Component\OptionsResolver\OptionsResolver;
2424

2525
/**
26-
* Execute one or many processes while chaining inputs in a iterable way.
26+
* Execute a process for each input: the input is passed to the process entry point, and the output of its end point
27+
* becomes the task output.
2728
*/
2829
class ProcessExecutorTask extends AbstractConfigurableTask
2930
{

‎src/Task/RowAggregatorTask.php‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
use Symfony\Component\OptionsResolver\OptionsResolver;
2222

2323
/**
24-
* Wait for defined inputs before passing an aggregated output.
25-
* Should have been a BlockingTask, but due to limitations in the current model, it's a hack using skips and finalize.
26-
*
27-
* @see README.md:Known issues
24+
* Group input rows sharing the same value for the "aggregate_by" column. Each group is made of the first received row
25+
* (without the "aggregate_columns"), plus a sub-array under "aggregation_key" listing the "aggregate_columns" values of
26+
* every row of the group. The groups are output once all previous tasks are resolved.
2827
*/
2928
class RowAggregatorTask extends AbstractConfigurableTask implements BlockingTaskInterface
3029
{

‎src/Transformer/Date/DateFormatTransformer.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
use Symfony\Component\OptionsResolver\OptionsResolver;
1818

1919
/**
20-
* Transformer aiming to take a date as an input (object or string) and format it according to options.
21-
* In input it takes any value understood by \DateTime.
20+
* Transformer aiming to take a date object (\DateTimeInterface) as an input and format it according to options.
2221
*
2322
* @example in YML config
2423
* transformers:

‎src/Transformer/DefaultTransformer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\OptionsResolver\OptionsResolver;
1717

1818
/**
19-
* @todo vclavreul comment this class
19+
* Return a default value when the input is falsy, otherwise return the input unchanged.
2020
*/
2121
class DefaultTransformer implements ConfigurableTransformerInterface
2222
{

‎src/Transformer/ExpressionLanguageMapTransformer.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public function transform(mixed $value, array $options = []): mixed
7979
return $value;
8080
}
8181
if (!$options['ignore_missing']) {
82-
throw new \UnexpectedValueException("No expression accepting value '{$value}' in map");
82+
$printableValue = \is_scalar($value) || $value instanceof \Stringable ? (string) $value : get_debug_type($value);
83+
throw new \UnexpectedValueException("No expression accepting value '{$printableValue}' in map");
8384
}
8485

8586
return null;

‎src/Transformer/Object/RecursivePropertySetterTransformer.php‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
2121

2222
/**
23-
* Read a property from the input value and return it.
23+
* Read an iterable from the input, then set one or more properties on each of its items, using values read from the
24+
* input itself.
2425
*/
2526
class RecursivePropertySetterTransformer implements ConfigurableTransformerInterface
2627
{
@@ -44,26 +45,26 @@ public function transform(mixed $value, array $options = []): mixed
4445
throw new TransformerException($options['iterator']);
4546
}
4647

47-
$protertiesToSet = [];
48+
$propertiesToSet = [];
4849
foreach ($options['set_properties'] as $propertyName => $propertyValuePath) {
49-
$protertiesValue = null;
50+
$propertyValue = null;
5051
if (!$options['ignore_missing'] || $this->accessor->isReadable($value, $propertyValuePath)) {
51-
$protertiesValue = $this->accessor->getValue($value, $propertyValuePath);
52-
if (null === $protertiesValue && !$options['ignore_null']) {
52+
$propertyValue = $this->accessor->getValue($value, $propertyValuePath);
53+
if (null === $propertyValue && !$options['ignore_null']) {
5354
throw new TransformerException($propertyValuePath);
5455
}
5556
}
56-
$protertiesToSet[$propertyName] = $protertiesValue;
57+
$propertiesToSet[$propertyName] = $propertyValue;
5758
}
5859

5960
foreach ($iterable as &$item) {
60-
foreach ($protertiesToSet as $protertyName => $propertyValue) {
61+
foreach ($propertiesToSet as $propertyPath => $propertyValue) {
6162
try {
62-
$this->accessor->setValue($item, $protertyName, $propertyValue);
63+
$this->accessor->setValue($item, $propertyPath, $propertyValue);
6364
} catch (NoSuchPropertyException $e) {
6465
if ($item instanceof \stdClass) {
6566
$item = (object) array_merge((array) $item, [
66-
$protertyName => $propertyValue,
67+
$propertyPath => $propertyValue,
6768
]);
6869
} else {
6970
throw $e;

‎src/Transformer/RulesTransformer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function configureOptions(OptionsResolver $resolver): void
7676
foreach ($rules as $rule) {
7777
if ($rule['default']) {
7878
if ($hasFoundDefault) {
79-
throw new \InvalidArgumentException('Rules set cannot have more than 2 default rules');
79+
throw new \InvalidArgumentException('Rules set cannot have more than one default rule');
8080
}
8181
$hasFoundDefault = true;
8282
}

0 commit comments

Comments
 (0)