|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +PHP library for running shell processes in parallel with dependency management between them. Built on Symfony Console/Process components. The library itself is used to run its own CI validation (self-dogfooding). |
| 8 | + |
| 9 | +## Common Commands |
| 10 | + |
| 11 | +**Run tests locally (requires PHP 8.2+ and ext-pcntl):** |
| 12 | +```bash |
| 13 | +composer install |
| 14 | +vendor/bin/phpunit -c config/ci/phpunit.xml |
| 15 | +``` |
| 16 | + |
| 17 | +**Run full CI validation (runs all checks in parallel using this library itself):** |
| 18 | +```bash |
| 19 | +bin/ci/env # install dependencies |
| 20 | +bin/ci/validate # runs phpcs, phpstan, phpunit, composer checks, etc. in parallel |
| 21 | +``` |
| 22 | + |
| 23 | +**Run individual CI tools:** |
| 24 | +```bash |
| 25 | +bin/ci/phpcs # code style (steevanb custom sniffs) |
| 26 | +bin/ci/phpstan # static analysis (level 9) |
| 27 | +bin/ci/phpunit-coverage # tests with coverage |
| 28 | +``` |
| 29 | + |
| 30 | +CI tests across a matrix: PHP 8.2/8.3/8.4 × Symfony 7.0/7.1/7.2/7.3. |
| 31 | + |
| 32 | +## Architecture |
| 33 | + |
| 34 | +### Core Components |
| 35 | + |
| 36 | +**`ParallelProcessesApplication`** (`src/Console/Application/`) — Main orchestrator. Extends Symfony `SingleCommandApplication`, implements `SignalableCommandInterface`. Uses a fluent builder interface to add processes, configure timeout/refresh interval/max parallel processes, then `run()`. Handles SIGINT for graceful shutdown. |
| 37 | + |
| 38 | +**`Process`** (`src/Process/Process.php`) — Extends Symfony `Process`, implements `ProcessInterface`. Each process has configurable output verbosity levels (standard, error, failure, canceled), a `StartCondition` for dependency management, and cancellation support. |
| 39 | + |
| 40 | +**`StartCondition`** (`src/Process/StartCondition.php`) — Controls when a process can start via three dependency collections: |
| 41 | +- `processesTerminated` — start after these finish (regardless of success/failure) |
| 42 | +- `processesSuccessful` — start only after these succeed |
| 43 | +- `processesFailed` — start only after these fail |
| 44 | + |
| 45 | +**`BootstrapProcess` / `TearDownProcess`** — Special process types. Bootstrap processes automatically become dependencies (via `processesSuccessful`) for all standard processes. TearDown processes automatically wait for all standard processes to terminate. |
| 46 | + |
| 47 | +**Theme system** (`src/Console/Application/Theme/`) — Strategy pattern. `DefaultTheme` shows real-time colored status; `SummaryTheme` shows minimal output (used in CI). Custom themes implement `ThemeInterface`. Selected via `--theme` CLI option. |
| 48 | + |
| 49 | +**`ProcessInterfaceCollection`** — Type-safe collection with filtering: `getReady()`, `getStarted()`, `countRunning()`. |
| 50 | + |
| 51 | +## Code Conventions |
| 52 | + |
| 53 | +- `declare(strict_types=1)` on every file |
| 54 | +- PHP 8.2+ features: constructor property promotion, `readonly`, enums, `#[\Override]` attribute |
| 55 | +- PHPStan level 9 (strictest) |
| 56 | +- Fluent interface pattern (methods return `static`) |
| 57 | +- Interfaces suffixed with `Interface`, no `Abstract` prefix convention |
| 58 | +- Tests: one test class per method, `@covers` annotation required, test directory mirrors `src/` structure |
| 59 | +- PHPUnit config: `config/ci/phpunit.xml` (with coverage), `config/release/phpunit.xml` |
| 60 | +- PHPStan configs: `config/ci/phpstan/` (per PHP/Symfony version combination) |
0 commit comments