Skip to content

Promote --generate-baseline to a first-class generate-baseline command#656

Merged
fain182 merged 2 commits into
mainfrom
claude/application-class-design-d4dfes
Jul 17, 2026
Merged

Promote --generate-baseline to a first-class generate-baseline command#656
fain182 merged 2 commits into
mainfrom
claude/application-class-design-d4dfes

Conversation

@fain182

@fain182 fain182 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

New Feature

Q A
New Feature yes
RFC no
BC Break yes (intentional, see below)
Issue Close #648

Summary

Second and final step of the series started with #655 (the CommonOptions extraction): check --generate-baseline was an action disguised as an option — it ran a completely different flow, printed no violations and always returned success. It becomes a dedicated command:

phparkitect generate-baseline [filename]
  • New GenerateBaseline command with an optional filename argument (defaults to phparkitect-baseline.json, same as before), backed by a GenerateBaselineHandler / GenerateBaselineOptions pair mirroring the check command's structure. It composes the CommonOptions collaborator 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. CheckHandler loses generateBaseline() and is now only about checking.
  • Fail-fast migration as specified in the issue: check --generate-baseline now exits with code 1 and points to the new command, echoing back the filename if one was passed:
    ❌ The --generate-baseline option has been moved to its own command.
       Run: phparkitect generate-baseline my-baseline.json
    
    The option is deliberately kept as a failing stub — removing it would surface Symfony's generic "option does not exist" error instead of a migration hint.

Two deliberate choices worth reviewing:

  • --target-php-version is included in the new command even though Promote --generate-baseline from a check option to a first-class generate-baseline command #648 didn't list it: the baseline should be generated with the same parser settings as the check runs that will consume it.
  • Unlike the old flag flow, generate-baseline does 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-baseline path. 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 in CheckCommandTest); 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

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

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.14815% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.28%. Comparing base (557c44b) to head (4cab831).

Files with missing lines Patch % Lines
src/CLI/Command/GenerateBaseline.php 95.23% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             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     
Files with missing lines Coverage Δ
src/CLI/Baseline.php 96.66% <100.00%> (+2.72%) ⬆️
src/CLI/CheckHandler.php 100.00% <100.00%> (ø)
src/CLI/CheckOptions.php 100.00% <ø> (ø)
src/CLI/Command/Check.php 100.00% <100.00%> (ø)
src/CLI/Command/CommandRuntime.php 100.00% <100.00%> (ø)
src/CLI/Command/CommonOptions.php 100.00% <100.00%> (ø)
src/CLI/GenerateBaselineHandler.php 100.00% <100.00%> (ø)
src/CLI/GenerateBaselineOptions.php 100.00% <100.00%> (ø)
src/CLI/PhpArkitectApplication.php 100.00% <100.00%> (ø)
src/CLI/Command/GenerateBaseline.php 95.23% <95.23%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…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
fain182 marked this pull request as ready for review July 17, 2026 14:17
@fain182
fain182 merged commit 88a3138 into main Jul 17, 2026
35 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.

Promote --generate-baseline from a check option to a first-class generate-baseline command

2 participants