Fix --config option when placed before the command name#46
Merged
Conversation
The Entropy input parser mishandles a leading long option: the first argv
token is force-parsed as a boolean flag, so "ecs --config=ecs.php" turned
into a bogus "config=ecs.php" flag and failed with 'Unknown option'.
Options after the command name ("ecs check --config=ecs.php") worked.
Inject the default "check" command in ecs_normalize_argv() when the first
real argument is an option, so the parser's main loop handles it correctly.
Help flags stay untouched to keep the global "--help" listing.
Adds a config_option.yaml CI workflow that runs the real binary with
--config in every position.
CI installs the latest deps (composer.lock is not committed), so it runs rector 2.5.5, which flags AbstractDocBlockFixer with early-return rules. Bump the constraint to ^2.5 and apply the required refactor, so the Rector job passes.
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.
Problem
The
--configoption failed when placed before the command name (or when running the default command with no command name):ecs check --config=ecs.php(option after the command) worked, hence it looked like--configwas gone after the symfony/console → entropy migration.Reported in #27 (comment).
Root cause
The Entropy input parser force-parses the first argv token as a boolean flag:
Only the boolean-flag case is handled; a leading
--long=value/--long valueis mangled. The parser's main loop handles them correctly, so options after the command name always worked.Fix
In
ecs_normalize_argv()(already the layer that adapts argv for Entropy), inject the defaultcheckcommand when the first real argument is an option, so the working loop parses it. Help flags stay untouched so the global--helplisting is preserved.Before / after
Test
New
config_option.yamlCI workflow runs the real binary with--configin every position (--config=x,--config x,check --config=x) and asserts the custom config loads and noUnknown optionis printed.