Guidance for Claude Code when working in this repository.
Symplify EasyCodingStandard (ECS) — a unified runner for PHP-CS-Fixer and PHP_CodeSniffer. Users configure rules through a fluent PHP API (ECSConfig::configure()->with...()) instead of dealing with each tool's native config format.
- PHP
>=8.3 - Entry binary:
bin/ecs - PSR-4:
Symplify\EasyCodingStandard\→src/ - Tests PSR-4:
Symplify\EasyCodingStandard\Tests\→tests/
Run all three, in this order. Fix anything that fails before reporting work as done.
composer phpstan # vendor/bin/phpstan analyse (level 8, src + tests + ecs.php + rector.php)
composer rector # vendor/bin/rector process --dry-run
composer check-cs # bin/ecs checkShortcut for all three: composer lint.
To auto-apply Rector and ECS fixes: composer lint.fix (runs fix-rector then fix-cs).
Tests: composer test (PHPUnit). Run them when behavior may have changed.
Memory limit for PHPStan and Rector is 1G (already set in composer scripts).
src/Config/ECSConfig.php— Illuminate container subclass, low-level rule registration (rule(),ruleWithConfiguration(),sets(),import()). Auto-tags Sniff/FixerInterface/OutputFormatterInterface bindings.src/Configuration/ECSConfigBuilder.php— fluent user-facing API (withRules,withSets,withPreparedSets,withPhpCsFixerSets,withSpacesLevel, …). Returned byECSConfig::configure().__invoke(ECSConfig)flushes the builder state into the container.config/set/common/*.php— prepared rule sets (spaces, arrays, namespaces, docblock, etc.); each returns a closure consumed byECSConfig::import().src/Config/Level/— gradual-adoption levels (e.g.SpacesLevel). Each level class exposesRULES(ordered safest → most invasive) and optionallyRULE_CONFIGURATIONS.src/Configuration/Levels/LevelRulesResolver.php— resolvesint $levelto the first N+1 rules from a level'sRULESarray. Clamps to max, throws on negative input or empty rule list.
- Create
src/Config/Level/<Name>Level.phpwithRULES(ordered) andRULE_CONFIGURATIONS(only for configurable rules). - Add
with<Name>Level(int $level): selftoECSConfigBuilder. UseLevelRulesResolver::resolve(), then route configurable rules to$this->rulesWithConfigurationand the rest to$this->rules.
declare(strict_types=1);on every PHP file.finalclasses by default.- PHPStan level 8,
type_coverage.return: 99. Keep new code fully typed. - Don't introduce new comments unless they explain a non-obvious why; well-named identifiers should carry meaning.
- Don't add backwards-compat shims, dead re-exports, or features that aren't required by the task.
illuminate/container is patched via patches/illuminate-container-container-php.patch (cweagans/composer-patches). Don't update the package without re-checking the patch.
scoper.php and prefix-code.sh / full_ecs_build.sh produce the prefixed distribution. Don't edit scoper.php casually; it's excluded from PHPStan.
- Don't bypass
phpstan,rector, orcheck-cswith skip comments unless the user asks for it. - Don't run
lint.fixorfix-csautomatically when the user only asked for analysis — the autofix changes files. - Don't push, force-push, or open PRs unless explicitly asked.