#206 - Fix AdvancedStatCounterTask, IterableBatchTask, ConditionTrait and ColumnAggregatorTask edge cases - #217
Merged
Merged
Conversation
…ionTrait 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. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #206.
Four tasks or helpers fail on edge cases:
AdvancedStatCounterTasktestscounter % show_everybefore incrementing the counter: the first counted execution is never logged and the reported item count is one behind. Withshow_every: 1, 3 executions give: nothing, "1 items processed", "2 items processed".IterableBatchTaskonly accepts an integerbatch_count: thenull !== $batchCountbranch ("only flush at the end", as inSimpleBatchTask) is dead code, andbatch_count: ~throws.ConditionTrait::checkValue(),checkEmpty()andgetValue()are typedobject|array: as soon as a condition is set, a scalar input raises aTypeError. The documented''path, which targets the whole value, is therefore unusable on scalars, e.g.array_filteron a list of strings.ColumnAggregatorTaskusesisset()to detect missing columns, so a column whose value isnullcounts as missing and throws anUnexpectedValueException.This PR:
AdvancedStatCounterTask: increment the counter before theshow_everytest, so statistics are logged on the N-th, 2N-th… counted execution, with the right item count.IterableBatchTask: allow['integer', 'null']forbatch_count;nullbuffers every input and outputs them one by one on flush, likeSimpleBatchTask.ConditionTrait: type$inputasmixed; the''path targets the whole value, even a scalar; any other path on a scalar givesnull, like a missing key.ColumnAggregatorTask: detect missing columns witharray_key_exists()for array inputs, sonullcolumns are aggregated (ArrayAccessinputs keep theisset()check).The new regression tests fail on
mainand pass with this fix. PHPUnit, PHPStan, PHP-CS-Fixer and Rector pass.Requirements
Breaking changes
None intended (bug fixes), but behaviour changes slightly:
AdvancedStatCounterTasknow logs one execution earlier (on the N-th counted execution instead of the (N+1)-th), with correct item counts.ColumnAggregatorTasknow aggregates rows whose column value isnullinstead of throwing (or only warning withignore_missing: true).ConditionTraitmethods now declare amixed$input: a class overridingcheckValue(),checkEmpty()orgetValue()with the oldobject|arraysignature must widen it.🤖 Generated with Claude Code