Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstan Webmozart Assert Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Supports static analysis investment by enhancing PHPStan's ability to infer types after webmozart/assert validations, reducing runtime errors without manual type hints
  • Justifies build vs. buy for type safety tooling: avoids custom rule development by leveraging a maintained, low-risk extension
  • Enables roadmap alignment for teams prioritizing code quality, with immediate ROI in bug prevention and developer productivity
  • Critical use case: large-scale PHP projects with strict typing requirements where assertions are heavily used for input validation

When to Consider This Package

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.

How to Pitch It (Stakeholders)

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

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport