Skip to content

Commit f0f1975

Browse files
committed
chore: help with phpstan troubleshot
1 parent a2d901c commit f0f1975

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,34 @@ composer link ../../
4949
./vendor/bin/phpunit
5050
```
5151

52-
4. Coding Standards & Conventions
52+
4. Static Analysis (PHPStan)
53+
54+
**Prerequisites:** You must run at least one PHPUnit test to warm up the cache before running PHPStan. PHPStan relies on the generated cache (autoload, proxies, etc.) to resolve classes correctly.
55+
56+
```
57+
vendor/bin/phpstan analyse src/YourComponent
58+
```
59+
60+
* MongoDB Stubs: PHPStan may fail with errors about missing MongoDB classes. Fix by installing the MongoDB ODM packages:
61+
62+
```
63+
composer require --dev doctrine/mongodb-odm-bundle doctrine/mongodb-odm
64+
```
65+
66+
* Stale vendor directories: Nested `vendor/` dirs inside `src/` components can confuse PHPStan. Clean them up with:
67+
68+
```
69+
find src -name vendor -exec rm -r {} \;
70+
```
71+
72+
5. Coding Standards & Conventions
5373

5474
* Imports: Grouped by type (class, function, const), sorted alphabetically.
5575
* Modern PHP 8+
5676
* Static Providers: If DB persistence isn't required, use a static provider in the ApiResource (see Product.php pattern).
5777
* New Entities: If persistence is required, create a new Entity class (e.g., NewFeatureEntity.php) rather than adding fields to existing ones.
5878

59-
5. Git & Contribution
79+
6. Git & Contribution
6080

6181
* Commit Messages: Follow Conventional Commits (type(scope): description).
6282
* Backwards Compatibility: Never break BC.

0 commit comments

Comments
 (0)