Skip to content

Add experimental --turbo option running the reco Go binary - #80

Merged
TomasVotruba merged 3 commits into
mainfrom
add-turbo-reco-option
Sep 24, 2026
Merged

TomasVotruba merged 3 commits into
mainfrom
add-turbo-reco-option

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

What

Adds an experimental --turbo flag to bin/ecs check. Instead of running the PHP engine, it hands the resolved paths to the reco Go binary - a PHP parser and rewriter written in Go.

vendor/bin/ecs check --turbo          # report only (dry run)
vendor/bin/ecs check --turbo --fix    # rewrite files in place
vendor/bin/ecs check src --turbo      # path before the flag

How

  • ECS resolves the source paths from ecs.php (and any CLI paths) exactly as usual, then invokes reco over them.
  • The check/fix split maps straight onto reco:
    • --turbo runs reco run --dry-run <paths> - reports without writing.
    • --turbo --fix runs reco run <paths> - rewrites in place.
  • Binary resolution order: ECS_TURBO_BIN env var -> vendor/bin/reco -> reco on PATH.
  • reco's exit code is mapped onto ECS exit codes (0 stays success, non-zero becomes CHANGED_CODE_OR_FOUND_ERRORS).
  • symfony/process is in replace, so the shell-out uses passthru with escaped arguments.

Prototype caveat

This is an RFC-stage prototype. In turbo mode reco runs its own native rule set, not the sniffs and fixers configured in ecs.php - only the paths are shared, the rule selection is ignored for now. A turbo run is not yet equivalent to a normal ECS run. This is documented in docs/turbo.md.

Remaining delivery work

For --turbo to work out of the box the reco binary has to ship alongside ECS:

  • ship reco as downloadable per-OS binaries via goreleaser releases;
  • add a Composer post-install step that downloads the matching binary into vendor/bin/reco.

Until then, build reco and point ECS_TURBO_BIN at it, or put it on PATH.

Tests

New unit tests under tests/Turbo. composer lint (phpstan level 8 + rector + check-cs) and composer test pass locally.

Turbo mode now resolves the full ecs.php config - paths, rules (with each
fixer's configuration) and skips - dumps it to a temp JSON file, and passes
it to reco via --ecs-config, so reco maps the ECS rules to its native ones
rather than running a fixed set. The same JSON is exposed standalone via a
new dump-config command. RecoConfigDumper builds the JSON; TurboRunner
writes and runs it.
The config consumer now lives in tomasvotruba/ecs-go, whose fixers are named
by their PHP-CS-Fixer class, so the dumped config maps across by name. Rename
RecoBinaryLocator to EcsGoBinaryLocator (locating ecs-go / vendor/bin/ecs-go,
ECS_TURBO_BIN unchanged) and RecoConfigDumper to TurboConfigDumper, and adjust
the invocation: ecs-go reports by default and rewrites with --fix, so turbo
passes --ecs-config <file> and adds --fix in fix mode.
@TomasVotruba
TomasVotruba merged commit d5e1e70 into main Sep 24, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the add-turbo-reco-option branch September 24, 2026 09:03
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.

1 participant