Skip to content

Commit 63e0964

Browse files
phpstan-botclaude
andcommitted
Add CLAUDE.md with project documentation
Comprehensive guide covering project goal, repository structure, PHP version requirements, development commands, coding standard, testing, CI pipeline, and how the extension works. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 183b6dd commit 63e0964

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# CLAUDE.md
2+
3+
This is the `phpstan/phpstan-dibi` repository — a PHPStan extension for the [Dibi](https://dibi.nette.org/) database library.
4+
5+
## Project Goal
6+
7+
This extension teaches PHPStan about dynamic methods on `Dibi\Fluent`. Dibi's fluent query builder uses `__call()` to handle SQL clause methods (like `->select()`, `->where()`, `->orderBy()`, etc.) dynamically. Without this extension, PHPStan would report errors for every such method call. The extension tells PHPStan that any method called on `Dibi\Fluent` is valid, accepts variadic arguments, and returns `Dibi\Fluent` (for chaining).
8+
9+
The extension also registers `Dibi\Row` as a universal object crate (dynamic property access without errors).
10+
11+
## Repository Structure
12+
13+
```
14+
src/
15+
Reflection/Dibi/
16+
DibiFluentClassReflectionExtension.php # MethodsClassReflectionExtension implementation
17+
DibiFluentMethodReflection.php # MethodReflection for dynamic Dibi\Fluent methods
18+
tests/
19+
Reflection/Dibi/
20+
DibiFluentClassReflectionExtensionTest.php # Unit tests
21+
bootstrap.php
22+
extension.neon # PHPStan extension config (registered service + parameters)
23+
phpstan.neon # PHPStan config for analysing this project itself
24+
phpunit.xml # PHPUnit configuration
25+
composer.json # Composer package definition
26+
Makefile # Build commands
27+
```
28+
29+
## PHP Version Requirement
30+
31+
This project supports **PHP 7.4+**. The composer.json platform is set to `7.4.6`. Do not use PHP 8.0+ syntax (named arguments, union types in declarations, match expressions, constructor promotion, etc.) in the source code.
32+
33+
## Dependencies
34+
35+
- **phpstan/phpstan**: `^2.0` (required)
36+
- **dibi/dibi**: conflicts with `<3.0`, dev dependency on `~4.0`
37+
38+
## Development Commands
39+
40+
All commands are defined in the `Makefile`:
41+
42+
- `make check` — runs all checks (lint, cs, tests, phpstan)
43+
- `make tests` — runs PHPUnit tests
44+
- `make lint` — runs php-parallel-lint on `src/` and `tests/`
45+
- `make cs` — runs PHP_CodeSniffer with phpstan/build-cs coding standard
46+
- `make cs-fix` — auto-fixes coding standard violations
47+
- `make cs-install` — clones and installs the phpstan/build-cs coding standard (2.x branch)
48+
- `make phpstan` — runs PHPStan at level 8 on `src/` and `tests/`
49+
50+
## Coding Standard
51+
52+
This project uses [phpstan/build-cs](https://github.com/phpstan/build-cs) (2.x branch) for coding standards enforcement via PHP_CodeSniffer. To set it up locally, run `make cs-install` before `make cs`.
53+
54+
## Testing
55+
56+
Tests use PHPUnit 9.6 with the `PHPStan\Testing\PHPStanTestCase` base class. Test files are in `tests/` and follow the same namespace structure as `src/`. Test classes must end with `Test.php`.
57+
58+
## CI Pipeline
59+
60+
The GitHub Actions workflow (`.github/workflows/build.yml`) runs on the `2.0.x` branch and pull requests:
61+
62+
- **Lint**: PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4
63+
- **Coding Standard**: PHP 8.2
64+
- **Tests**: PHP 7.4–8.4, both lowest and highest dependency versions
65+
- **PHPStan**: PHP 7.4–8.4, both lowest and highest dependency versions
66+
67+
## How the Extension Works
68+
69+
1. `extension.neon` registers `DibiFluentClassReflectionExtension` as a `phpstan.broker.methodsClassReflectionExtension` service.
70+
2. `DibiFluentClassReflectionExtension::hasMethod()` returns `true` for any method on `Dibi\Fluent`.
71+
3. `DibiFluentClassReflectionExtension::getMethod()` returns a `DibiFluentMethodReflection` that describes the method as public, non-static, variadic, and returning `Dibi\Fluent`.
72+
4. `Dibi\Row` is registered as a universal object crate in `extension.neon` parameters.
73+
74+
## Branch
75+
76+
The main development branch is `2.0.x`.

0 commit comments

Comments
 (0)