Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 20 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ composer ic:init
```text
Install CaptainHook pre-commit config (validate, audit, parallel CI)?
Install GitHub Actions workflow wrapper (parallel CI, SARIF, SVG report)?
PHPForge checker config preset
Install Deptrac architecture config (deptrac.yaml)?
Install GitLab CI pipeline (.gitlab-ci.yml)?
Install Bitbucket pipeline (bitbucket-pipelines.yml)?
Install Forgejo workflow (.forgejo/workflows/security-standards.yml)?
Expand Down Expand Up @@ -113,7 +111,6 @@ Selector presets include:
| Extra Composer flags | `none` => `""`, `with-all-dependencies` => `--with-all-dependencies`, `ignore-ext-redis` => `--ignore-platform-req=ext-redis`, or custom. Prompt explains each option effect. |
| PHPStan memory limit | `1G`, `2G`, `4G`, or custom |
| Psalm threads | `1`, `2`, `4`, or custom |
| PHPForge checker config preset | `phpstorm`, `standard`, or `strict`. Asked only when publishing `phpforge.json`. |

`supported` includes non-EOL PHP minor cycles (>= `8.2`), `current` uses the latest two supported cycles, and `stable` uses the latest supported cycle.
PHP version, dependency matrix, PHP extensions, and Composer flags selectors show resolved values in the prompt and print the final resolved value after selection.
Expand All @@ -122,15 +119,13 @@ Depending on your selections, `ic:init` can generate:

```text
captainhook.json
phpforge.json
deptrac.yaml
.github/workflows/security-standards.yml
.gitlab-ci.yml
bitbucket-pipelines.yml
.forgejo/workflows/security-standards.yml
```

Interactive init asks for a PHPForge checker config preset and publishes `phpforge.json` from that choice. It also asks whether to publish `deptrac.yaml`. Non-interactive default init still keeps bundled fallbacks unless `--phpforge` or `--deptrac` is passed. Use `composer ic:publish-config phpforge.json deptrac.yaml` when you only want to publish those files outside init.
`ic:init` sets up hook/workflow wrappers only. Publish checker or architecture config separately with `composer ic:publish-config phpprobe.json deptrac.yaml` when customization is needed.

After `ic:init`, run:

Expand All @@ -147,8 +142,6 @@ Use targeted or non-interactive init commands when needed:

```bash
composer ic:init --captainhook
composer ic:init --phpforge
composer ic:init --deptrac
composer ic:init --workflow --workflow-ref=main
composer ic:init --gitlab-ci
composer ic:init --bitbucket-ci
Expand All @@ -167,36 +160,36 @@ composer ic:init --force
| `composer ic:tests:all` | Alias of `ic:tests`. |
| `composer ic:tests:parallel` | Runs syntax first, then executes the remaining quality checks with bounded parallelism and a buffered PASS/FAIL summary. |
| `composer ic:tests:details` | Runs detailed checks without the parallel Pest shortcut. |
| `composer ic:test:syntax` | Runs the PHP syntax checker using `phpforge.json`, Git ignores, and configured excludes. |
| `composer ic:test:syntax` | Runs the PHP syntax checker using `phpprobe.json`, Git ignores, and configured excludes. |
| `composer ic:test:code` | Runs Pest. |
| `composer ic:test:lint` | Runs Pint in check mode. |
| `composer ic:test:sniff` | Runs PHPCS with a full report against the project root and bundled/project excludes. |
| `composer ic:test:duplicates` | Runs duplicate detection using `phpforge.json`. |
| `composer ic:test:duplicates` | Runs duplicate detection using `phpprobe.json`. |
| `composer ic:test:architecture` | Runs Deptrac architecture checks using `deptrac.yaml`. |
| `composer ic:test:static` | Runs PHPStan. |
| `composer ic:test:security` | Runs Psalm security analysis. |
| `composer ic:test:refactor` | Runs Rector in dry-run mode. |
| `composer ic:test:bench` | Runs PHPBench aggregate benchmarks. |

Syntax and duplicate settings live in `phpforge.json`, with the bundled default used when a project-local file is not present.
Syntax and duplicate settings live in `phpprobe.json`, with the bundled default used when a project-local file is not present.
PHPForge delegates these checks to `vendor/bin/phpprobe`; the `phpforge syntax` and `phpforge duplicates` commands are thin compatibility gateways that pass the same config to PHPProbe.
Both checks are root-scoped by default because their bundled `paths` lists are empty; Git-aware PHP discovery is then filtered by the configured `exclude` lists.
Duplicate detection defaults are aligned with PhpStorm-style clone analysis: variable/literal normalization, fuzzy identifier/call anonymization, structural audit mode, near-miss matching, and a mid-sensitivity token window are enabled.
Use the lower-level binary for custom scans; CLI paths override configured paths, while CLI excludes are added to configured excludes:

```bash
php vendor/bin/phpprobe syntax --config=phpforge.json --exclude=storage
php vendor/bin/phpprobe duplicates --config=phpforge.json --min-lines=5 --min-tokens=70
php vendor/bin/phpprobe duplicates --config=phpforge.json --mode=audit --near-miss --json --exclude=tests
php vendor/bin/phpprobe duplicates --config=phpforge.json --write-baseline=.phpforge-duplicates-baseline.json
php vendor/bin/phpprobe duplicates --config=phpforge.json --baseline=.phpforge-duplicates-baseline.json
php vendor/bin/phpprobe syntax --config=phpprobe.json --exclude=storage
php vendor/bin/phpprobe duplicates --config=phpprobe.json --min-lines=5 --min-tokens=70
php vendor/bin/phpprobe duplicates --config=phpprobe.json --mode=audit --near-miss --json --exclude=tests
php vendor/bin/phpprobe duplicates --config=phpprobe.json --write-baseline=.phpprobe-duplicates-baseline.json
php vendor/bin/phpprobe duplicates --config=phpprobe.json --baseline=.phpprobe-duplicates-baseline.json
```

Useful checker options:

| Option | Applies To | Purpose |
| --------------------------- | ------------------ | ----------------------------------------------------------------------- |
| `--config=FILE` | Syntax, duplicates | Reads checker settings from a custom `phpforge.json` file. |
| `--config=FILE` | Syntax, duplicates | Reads checker settings from a custom `phpprobe.json` file. |
| `--exclude=PATH` | Syntax, duplicates | Excludes one path; repeat it for multiple one-off exclusions. |
| `--exact` | Duplicates | Disables variable/literal normalization. |
| `--fuzzy` | Duplicates | Also normalizes identifiers and calls for renamed-code scans. |
Expand Down Expand Up @@ -248,11 +241,8 @@ Useful checker options:

| Command | Purpose |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `composer ic:init` | Interactively sets up CaptainHook pre-commit, workflow wrappers, and checker config publishing. |
| `composer ic:init` | Interactively sets up CaptainHook pre-commit and workflow wrappers. |
| `composer ic:init --captainhook` | Copies only the CaptainHook pre-commit config. |
| `composer ic:init --phpforge` | Publishes `phpforge.json` only when a project needs custom syntax or duplicate detection settings. |
| `composer ic:init --phpforge --phpforge-preset=standard` | Publishes `phpforge.json` with a named preset: `phpstorm`, `standard`, or `strict`. |
| `composer ic:init --deptrac` | Copies only the Deptrac architecture config. |
| `composer ic:init --workflow --workflow-ref=main` | Copies only the GitHub Actions wrapper and points it at the given PHPForge ref. |
| `composer ic:init --gitlab-ci` | Copies `.gitlab-ci.yml` starter pipeline. |
| `composer ic:init --bitbucket-ci` | Copies `bitbucket-pipelines.yml` starter pipeline. |
Expand All @@ -265,6 +255,7 @@ Useful checker options:
| `composer ic:list-config` | Lists config files and their resolution source. |
| `composer ic:list-config --json` | Outputs config resolution as JSON. |
| `composer ic:publish-config [file...]` | Copies selected bundled config files into the project. |
| `composer ic:publish-config phpprobe.json --phpprobe-preset=strict` | Publishes `phpprobe.json` using a named duplicate-detection preset (`phpstorm`, `standard`, `strict`). |
| `composer ic:publish-config --all` | Copies every bundled config file into the project. |
| `composer ic:publish-config --all --force` | Overwrites all project config files with bundled defaults. |
| `composer ic:clean` | Removes known PHPForge output files and cache directories. |
Expand All @@ -286,7 +277,7 @@ If none of those exists outside the PHPForge source project, PHPForge fails inst
| ---------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Pest / PHPUnit | `pest.xml`, then `phpunit.xml`, then `pest.xml.dist`, then `phpunit.xml.dist`, then bundled `pest.xml` |
| PHPBench | `phpbench.json`, then bundled `phpbench.json` |
| PHPProbe checker tasks | `phpforge.json`, then bundled `phpforge.json` |
| PHPProbe checker tasks | `phpprobe.json`, then bundled `phpprobe.json` |
| Deptrac | `deptrac.yaml`, then bundled `deptrac.yaml` |
| PHPCS / PHPCBF | `phpcs.xml.dist`, then bundled `phpcs.xml.dist` |
| PHPStan | `phpstan.neon.dist`, then bundled `phpstan.neon.dist` |
Expand All @@ -297,7 +288,7 @@ If none of those exists outside the PHPForge source project, PHPForge fails inst

### PHPProbe Checker Config

`phpforge.json` configures PHPProbe syntax and duplicate-code checks.
`phpprobe.json` configures PHPProbe syntax and duplicate-code checks.
Both sections use root-scoped discovery when `paths` is empty: PHPProbe asks Git for tracked/unignored PHP files, then falls back to recursively scanning the project root if Git is unavailable.
Use `exclude` to keep tests, generated files, caches, vendor packages, and other noisy paths out of the checker tasks.

Expand Down Expand Up @@ -384,7 +375,7 @@ Bundled default:
Snake case, kebab case, and camel case are accepted for checker config keys, so `min_tokens`, `min-tokens`, and `minTokens` resolve to the same setting.
Explicit CLI paths override configured `paths`; configured and CLI excludes are combined.

PHPForge checker config presets are available when publishing `phpforge.json` through `ic:init --phpforge`:
Presets for `phpprobe.json` publishing:

| Preset | Duplicate Policy |
| ----------- | -------------------------------------------------------------------------------- |
Expand All @@ -393,8 +384,7 @@ PHPForge checker config presets are available when publishing `phpforge.json` th
| `strict` | More sensitive audit mode: near-miss matching enabled with lower size thresholds, `min_tokens: 70`. |

```bash
composer ic:init --phpforge
composer ic:init --phpforge --phpforge-preset=standard
composer ic:publish-config phpprobe.json --phpprobe-preset=standard
```

### Deptrac Architecture Config
Expand All @@ -403,7 +393,6 @@ composer ic:init --phpforge --phpforge-preset=standard

```bash
composer ic:test:architecture
composer ic:init --deptrac
composer ic:publish-config deptrac.yaml
```

Expand All @@ -417,7 +406,7 @@ composer ic:list-config --json
Publish config only when a project needs custom rules:

```bash
composer ic:publish-config phpforge.json pint.json phpstan.neon.dist
composer ic:publish-config phpprobe.json pint.json phpstan.neon.dist
composer ic:publish-config --all
```

Expand All @@ -430,7 +419,7 @@ pest.xml
phpunit.xml
phpbench.json
phpcs.xml.dist
phpforge.json
phpprobe.json
phpstan.neon.dist
pint.json
psalm.xml
Expand Down Expand Up @@ -913,10 +902,10 @@ Then open the workflow run and download `security-report`.
Publish the relevant config and edit it in the project:

```bash
composer ic:publish-config phpforge.json
composer ic:publish-config phpprobe.json
composer ic:publish-config phpstan.neon.dist
composer ic:publish-config psalm.xml
```

Project config files always take priority over bundled defaults.
For syntax or duplicate detector noise, adjust `phpforge.json` paths/excludes or duplicate thresholds first.
For syntax or duplicate detector noise, adjust `phpprobe.json` paths/excludes or duplicate thresholds first.
4 changes: 2 additions & 2 deletions resources/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- `composer ic:release:guard` - release gate.
- `composer ic:ci` / `composer ic:ci --prefer-lowest` - CI parity.
- `composer ic:init` / `composer ic:hooks` - project setup and hooks.
- `composer ic:publish-config phpforge.json` - customize syntax/duplicate scan policy.
- `composer ic:publish-config phpprobe.json` - customize syntax/duplicate scan policy.

## Resolution Flow

Expand All @@ -29,7 +29,7 @@
## Config And CI

- Config priority: project root config first, then `vendor/infocyph/phpforge/resources`, then source-tree `resources/` only when the current project is `infocyph/phpforge`; otherwise missing bundled configs hard fail.
- `phpforge.json` controls PHPProbe syntax and duplicate paths/excludes; empty `paths` means project-root discovery through Git-aware PHP file finding.
- `phpprobe.json` controls PHPProbe syntax and duplicate paths/excludes; empty `paths` means project-root discovery through Git-aware PHP file finding.
- Syntax and duplicate scans run through `vendor/bin/phpprobe` and respect Git ignores plus configured `exclude`/`exclude_paths` entries.
- Checker CLI paths override configured `paths`; CLI `--exclude` values are added to configured excludes.
- `deptrac.yaml` controls architecture boundary checks.
Expand Down
File renamed without changes.
Loading