Promote --generate-baseline to a first-class generate-baseline command#656
Merged
Conversation
Closes #648. check --generate-baseline was an action disguised as an option: it ran a different flow, printed no violations and always returned success. It is now a dedicated command: phparkitect generate-baseline [filename] - New GenerateBaseline command with an optional filename argument (defaults to phparkitect-baseline.json, same as before) and a GenerateBaselineHandler/GenerateBaselineOptions pair mirroring the check command's structure. It composes the CommonOptions collaborator introduced for this purpose, so the shared options (--config, --target-php-version, --autoload, --ignore-baseline-linenumbers) cannot drift between commands. CheckHandler loses generateBaseline() and is finally only about checking. - check --generate-baseline now fails fast with a pointer to the new command, echoing back the filename if one was passed. The option is kept as a failing stub on purpose: dropping it would surface Symfony's generic "option does not exist" error instead of a migration hint. - Unlike the old flag flow, generate-baseline does not load an existing baseline before running, so it cannot fail on a stale --use-baseline path; it also intentionally omits check-only options (--stop-on-failure, --format, --use-baseline, --skip-baseline) that had no effect on generation. - E2E tests for the new command and the migration error; baseline fixtures in CheckCommandTest now generate through the new command. - README and CLAUDE.md updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015K1TKiwtwkW7twBCTz758P
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #656 +/- ##
============================================
- Coverage 98.29% 98.28% -0.01%
- Complexity 724 737 +13
============================================
Files 90 94 +4
Lines 2050 2100 +50
============================================
+ Hits 2015 2064 +49
- Misses 35 36 +1
🚀 New features to boost your workflow:
|
…save Post-review cleanup of the generate-baseline PR: - The console plumbing duplicated verbatim between Check and GenerateBaseline (ini_set limits, progress creation, version heading, execution-time footer) moves to CommandRuntime, a collaborator both commands compose — same pattern as CommonOptions, no base class. isRunningAsPhar() stays on each command as a test seam, and the try/catch/stderr wiring stays inline since it is control flow, not shared behavior. - The custom SUCCESS_CODE/ERROR_CODE constants are replaced by Symfony's Command::SUCCESS/Command::FAILURE (same values, available since the minimum supported symfony/console). - Baseline::save() loses its nullable-filename fallback: the only caller always passes a filename (the command argument already defaults to Baseline::DEFAULT_FILENAME), so the null branch was unreachable and the default filename was declared in two places. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015K1TKiwtwkW7twBCTz758P
fain182
marked this pull request as ready for review
July 17, 2026 14:17
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.
New Feature
Summary
Second and final step of the series started with #655 (the
CommonOptionsextraction):check --generate-baselinewas an action disguised as an option — it ran a completely different flow, printed no violations and always returned success. It becomes a dedicated command:GenerateBaselinecommand with an optionalfilenameargument (defaults tophparkitect-baseline.json, same as before), backed by aGenerateBaselineHandler/GenerateBaselineOptionspair mirroring thecheckcommand's structure. It composes theCommonOptionscollaborator merged in Extract CommonOptions, composed by analysis-running commands #655, so the shared options (--config,--target-php-version,--autoload,--ignore-baseline-linenumbers) cannot drift between commands.CheckHandlerlosesgenerateBaseline()and is now only about checking.check --generate-baselinenow exits with code 1 and points to the new command, echoing back the filename if one was passed:Two deliberate choices worth reviewing:
--target-php-versionis included in the new command even though Promote--generate-baselinefrom acheckoption to a first-classgenerate-baselinecommand #648 didn't list it: the baseline should be generated with the same parser settings as thecheckruns that will consume it.generate-baselinedoes not load an existing baseline before running (that was an artifact of the shared code path), so generation can no longer fail on a stale--use-baselinepath. It also intentionally omits check-only options that had no effect on generation (--stop-on-failure,--format,--use-baseline,--skip-baseline).Covered by new unit tests (
GenerateBaselineHandlerTest) and E2E tests (GenerateBaselineCommandTest, plus the migration-error case inCheckCommandTest); the existing baseline E2E fixtures now generate through the new command. README and CLAUDE.md updated.Next up, in a separate PR:
prune-baseline(#649).🤖 Generated with Claude Code
https://claude.ai/code/session_015K1TKiwtwkW7twBCTz758P
Generated by Claude Code