phpstan/phpstan-webmozart-assert
PHPStan extension for webmozart/assert that teaches PHPStan how Assert::* calls narrow types. Supports many assertions (including nullOr*/all*) so values become non-null, specific scalars, instances, arrays, etc. after validation, improving static analysis accuracy.
This package should be adopted when your project already uses PHPStan (v1.0+) and webmozart/assert for validation logic. It’s ideal for codebases where precise type narrowing during static analysis would prevent common runtime errors (e.g., null values after nullOrString() checks). Prioritize this if your team struggles with false positives in PHPStan reports due to unhandled assertion types. Avoid it if you’re not using PHPStan, rely on alternative assertion libraries (e.g., Symfony Validator), or maintain a small project with minimal validation logic. It’s purely an additive tool for existing PHPStan workflows and offers no standalone value without both core dependencies.
For executives: "This tiny extension turns our existing static analysis into a proactive bug-prevention tool. By teaching PHPStan to understand webmozart/assert validations, it catches type-related errors before code reaches production—reducing firefight
How can I help you explore Laravel packages today?