#203 - Fix ProcessState::addErrorContextValue() TypeError on empty iterables and PropertySetterTask - #214
Merged
Conversation
… value type, so that iterable tasks on an empty iterable are skipped and PropertySetterTask reports the original exception instead of a `TypeError`. 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 #203.
ProcessState::addErrorContextValue()only acceptsstring|int|arrayvalues. When a task passes any other value (null,bool,float, object), a\TypeErroris thrown and the real behaviour or error is lost:ConstantIterableOutputTask,InputIteratorTask,YamlReaderTaskwith{}/[],SplitJoinLineTaskwith no line to produce):AbstractIterableOutputTask::execute()always addsiterator_keybefore checking the iterator. On an empty iteratorkey()isnull, so the process fails instead of skipping the task, as documented.bool,float,nullor object, theTypeErrorreplaces the original exception (e.g.NoSuchPropertyException).This PR:
$valueparameter ofProcessState::addErrorContextValue()tomixed.AbstractIterableOutputTask::execute(), additerator_keyonly when the iterator is valid: an empty iterable then produces no output and the task is skipped.property_setter_task.md,yaml_reader_task.md,split_join_line_task.md,03-custom_tasks.md), add unit tests.The new regression tests fail on
mainand pass with this fix. PHPUnit, PHPStan, PHP-CS-Fixer and Rector pass.Requirements
Breaking changes
None for callers. Widening a parameter type is backward compatible, except for a subclass of
ProcessStateoverridingaddErrorContextValue()with the old signature (it must widen$valuetomixed).🤖 Generated with Claude Code