Fix PHPStan failures in CCC
## Fix PHPStan failures in ai_context **Type:** Code quality **PHPStan level:** 2 **Status:** `./lint.sh` fails with **16 errors** ### Reproduce ```bash php -d memory_limit=512M vendor/bin/phpstan analyze web/modules/custom/ai_context \ --configuration=web/modules/custom/ai_context/phpstan.neon.dist ``` ### Errors (3 groups) **1. Entity field typing (1)** — `src/Entity/AiContextItem.php:270` `FieldDefinitionInterface` has no `setLabel()`. Narrow to `BaseFieldDefinition` before chaining setters. **2. Diff builder return types (5)** — `DynamicEntityReferenceFieldBuilder.php` (4), `ScopeMapFieldDiffBuilder.php` (1) Child methods lack explicit return types; add `: mixed`, `: array`, or `: void` to match `FieldDiffBuilderBase`. **3. Deprecated test helper (10)** — `tests/src/Traits/DynamicEntityReferenceTestTrait.php:19` Replace `static::getDrupalRoot()` with `$this->root` (deprecated in Drupal 11.4, removed in 13.0). Affects 10 kernel tests using the trait. ### Done when - PHPStan passes at level 2 with no baseline entries - `./lint.sh` green - Existing tests still pass ## AI usage - [x] AI assisted issue - [x] AI generated code
issue