mixed returns from Doctrine queries) to strict static analysis. Aligns with PHPStan’s broader goal of eliminating // @var annotations.final entities breaking proxies, mismatched field types) without manual reviews.QueryBuilder usage in services/controllers to ensure type-safe DQL (e.g., getResult() returning array<User> instead of mixed).literal-string constraints on DB queries to block SQL injection vectors via static analysis.Assert or custom exception handlers) for Doctrine checks. This package is static, not dynamic.phpstan.neon to recognize these (see Gedmo support)."This package lets our PHPStan static analyzer understand Doctrine ORM/ODM natively—catching bugs like invalid DQL queries, type mismatches in entities, or broken proxy generation before they hit production. For example, it’ll flag a final entity class that breaks Doctrine proxies, saving QA time. It’s a low-cost, high-impact upgrade to our code quality toolchain, with minimal dev overhead (just composer require). Teams using PHPStan will see faster feedback loops and fewer runtime Doctrine errors."
ROI:
literal-string constraints to block SQL injection via static analysis.*"This extends PHPStan to handle Doctrine like a first-class citizen. Key wins:
QueryBuilder without running queries.// @var with precise types for:
EntityManager::getRepository() → Repository<User>Query::getResult() → array<User> (not mixed).@GeneratedValue IDs).How to Start:
composer.json (dev dependency).phpstan.neon to include extension.neon and optionally rules.neon for DQL checks.objectManagerLoader (e.g., Symfony’s EntityManager).Trade-offs:
WHERE $userInput). Configure reportDynamicQueryBuilders: true to flag these.Example Impact:
// Before: No type safety
$query = $em->createQuery('SELECT u FROM User u');
$result = $query->getResult(); // mixed → runtime errors if User changes.
// After: Static types
$result = $query->getResult(); // array<User> → IDE autocompletion + early warnings.
```"
How can I help you explore Laravel packages today?