Repository navigation
#242 - Fix InputFileReaderTask: explicit exception when no file path is given as input - #250
Merged
Merged
Conversation
…pty 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. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 #242.
InputFileReaderTask::getOptions()only setfilenamewhen the input was notnull, and thefilenameoption is removed from the resolver: with anull(or non-string) input,FileReaderTask::execute()read an undefined key (PHP warningUndefined array key "filename") thenfile_exists(null)threw aTypeError.getOptions()now throws\UnexpectedValueException('No file path given as input')when the input is not a non-empty string, consistent withInputFolderBrowserTasksince Edge cases looping forever or failing with a TypeError: FileSplitterTask, PropertySetterTask, SlugifyTransformer, InputFolderBrowserTask, XmlFile #232;AbstractConfigurableTask::initialize()callsgetOptions()before any input exists,initialize()is overridden to only validate the options (parent::getOptions()), the same wayInputFolderBrowserTaskdoes;docs/reference/tasks/input_file_reader_task.md;InputFileReaderTaskTest::testThrowsWhenNoFilePathIsGivenAsInputfornull,''and an array (all fail onmain).PHPUnit (804 tests), PHPStan, PHP-CS-Fixer and Rector pass, and the changed files are valid PHP 8.2.
Requirements
Breaking changes
None: a
nullor non-string input currently ends with aTypeError. An empty string''already threw an\UnexpectedValueException, only its message changes (No file path given as inputinstead ofFile does not exists: '').🤖 Generated with Claude Code