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
39 changes: 39 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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/<Namespace>/` and implements `PHPStan\Rules\Rule<NodeType>`.

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/<Namespace>/<RuleName>.php` — implement `Rule<T>` where `T` is the AST node type from `PhpParser\Node`.
2. Register the class as a service in `extension.neon`.
3. Create `tests/Rules/<Namespace>/<RuleName>Test.php` — extend `PHPStan\Testing\RuleTestCase<YourRule>`.
4. Add a fixture file at `tests/Rules/<Namespace>/fixtures/<name>.php` with PHP code that triggers (and doesn't trigger) the rule.
5. Call `$this->analyse([__DIR__ . '/fixtures/<name>.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)`.
40 changes: 0 additions & 40 deletions CLAUDE.md

This file was deleted.

1 change: 1 addition & 0 deletions CLAUDE.md
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down