Skip to content

#232 - Fix edge cases looping forever or failing with a TypeError - #233

Merged
njoubert-cleverage merged 1 commit into
mainfrom
232
Sep 29, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
232

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #232.

Five edge cases, found while fixing #202, #203, #204, #205 and #208, either looped forever or failed with a raw PHP TypeError instead of an explicit error. This PR:

  1. FileSplitterTask: max_lines must be an integer greater than 0 (it used to loop forever with max_lines lower than 1). The options given as input ({ file_path: ..., max_lines: ... }) are now validated like the task options: they are resolved again after the merge, and input keys that are not options are ignored.
  2. PropertySetterTask: catches \Throwable instead of \Exception, so the property / value error context is also set when the PropertyAccessor throws a TypeError (e.g. on a scalar input).
  3. SlugifyTransformer: transliterator, replace and separator must be strings (setAllowedTypes(), as documented), instead of a TypeError in Transliterator::create() / trim().
  4. InputFolderBrowserTask: an empty input (null, '') with no folder being browsed throws an explicit \UnexpectedValueException('No folder path given as input') instead of TypeError: is_dir().
  5. XmlFile::write() (XmlWriterTask): throws the intended \RuntimeException('Could not generate the XML content') when DOMDocument::saveXML() fails, instead of TypeError: fwrite().

The reference documentation of the five classes is updated.

The 10 new tests fail on main and pass with this fix. PHPUnit (with coverage), PHPStan, PHP-CS-Fixer and Rector pass, and the changed files are valid PHP 8.2.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None: every affected case looped forever or threw a TypeError; it now throws an explicit exception (an InvalidOptionsException when resolving the options, for 1 and 3). For FileSplitterTask, input keys that are not options are no longer merged into the options (they were not used).

🤖 Generated with Claude Code

…Error`: validate FileSplitterTask `max_lines` (greater than 0, also when given as input), catch any `\Throwable` in PropertySetterTask, type SlugifyTransformer options, explicit exceptions in InputFolderBrowserTask (no folder path) and `XmlFile::write()` (`saveXML()` failure). Update documentation, add tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit ba31efc into main Sep 29, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edge cases looping forever or failing with a TypeError: FileSplitterTask, PropertySetterTask, SlugifyTransformer, InputFolderBrowserTask, XmlFile

1 participant