diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..6bdc7f6 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,39 @@ +# AI Agents Guidelines + +## Commands + +All commands must run inside the PHP container: + +```bash +docker compose run --rm php composer install +docker compose run --rm php composer test +docker compose run --rm php composer phpstan +docker compose run --rm php composer cs-fix +docker compose run --rm php composer cs-check +``` + +Run a single test file: + +```bash +docker compose run --rm php vendor/bin/phpunit tests/Rules/Psr/Psr20RuleTest.php +``` + +CI runs all three checks (`test`, `phpstan`, `cs-check`) on PHP 8.2, 8.3, 8.4 and 8.5. + +## Architecture + +PHPStan extension package. Each rule lives in `src/Rules//` and implements `PHPStan\Rules\Rule`. + +Rules are registered as services in `extension.neon` with tag `phpstan.rules.rule`. This file is the extension entry point declared in `composer.json` under `extra.phpstan.includes`. + +### Adding a new rule + +1. Create `src/Rules//.php` — implement `Rule` where `T` is the AST node type from `PhpParser\Node`. +2. Register the class as a service in `extension.neon`. +3. Create `tests/Rules//Test.php` — extend `PHPStan\Testing\RuleTestCase`. +4. Add a fixture file at `tests/Rules//fixtures/.php` with PHP code that triggers (and doesn't trigger) the rule. +5. Call `$this->analyse([__DIR__ . '/fixtures/.php'], [...expected errors with message + line...])` in the test. + +### Code style + +php-cs-fixer enforces PSR-12 + `declare_strict_types`, `strict_param`, `no_unused_imports`, `ordered_imports` (alpha). All source files must have `declare(strict_types=1)`. diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index d3ab0f3..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,40 +0,0 @@ -# CLAUDE.md - -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. - -## Commands - -All commands must run inside the PHP container: - -```bash -docker compose run --rm php composer install -docker compose run --rm php composer test -docker compose run --rm php composer phpstan -docker compose run --rm php composer cs-fix -docker compose run --rm php composer cs-check -``` - -Run a single test file: -```bash -docker compose run --rm php vendor/bin/phpunit tests/Rules/Psr/Psr20RuleTest.php -``` - -CI runs all three checks (`test`, `phpstan`, `cs-check`) on PHP 8.2, 8.3, 8.4 and 8.5. - -## Architecture - -PHPStan extension package. Each rule lives in `src/Rules//` and implements `PHPStan\Rules\Rule`. - -Rules are registered as services in `extension.neon` with tag `phpstan.rules.rule`. This file is the extension entry point declared in `composer.json` under `extra.phpstan.includes`. - -### Adding a new rule - -1. Create `src/Rules//.php` — implement `Rule` where `T` is the AST node type from `PhpParser\Node`. -2. Register the class as a service in `extension.neon`. -3. Create `tests/Rules//Test.php` — extend `PHPStan\Testing\RuleTestCase`. -4. Add a fixture file at `tests/Rules//fixtures/.php` with PHP code that triggers (and doesn't trigger) the rule. -5. Call `$this->analyse([__DIR__ . '/fixtures/.php'], [...expected errors with message + line...])` in the test. - -### Code style - -php-cs-fixer enforces PSR-12 + `declare_strict_types`, `strict_param`, `no_unused_imports`, `ordered_imports` (alpha). All source files must have `declare(strict_types=1)`. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..47dc3e3 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 439b16f..2bd4b16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,7 +115,7 @@ CI runs `test`, `phpstan`, and `cs-check` against PHP 8.2, 8.3, 8.4, and 8.5. Al ## AI agents -If you are contributing via an AI coding agent (Claude Code), refer to [CLAUDE.md](CLAUDE.md) — it contains the machine-readable instructions for this repository. +If you are contributing via an AI coding agent, refer to [AGENTS.md](AGENTS.md) — it contains the machine-readable instructions for this repository. ## Code style diff --git a/README.md b/README.md index 9fd0d4a..f70eb76 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ final class MyService See [CONTRIBUTING.md](CONTRIBUTING.md) for the human contributor guide. -If you are working with an AI agent (Claude Code), refer to [CLAUDE.md](CLAUDE.md) — it contains the AI-facing instructions for this repository. +If you are working with an AI agent, refer to [AGENTS.md](AGENTS.md) — it contains the AI-facing instructions for this repository. ## License