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 Phpunit Laravel Package

phpstan/phpstan-phpunit

PHPStan extension for PHPUnit: improves type inference for mocks (intersection types for createMock/getMock), understands Foo|MockObject phpDocs, adds early-terminating methods to avoid undefined vars, and refines assert() types. Optional strict rules catch improper assertion usage.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enhances test reliability by enforcing correct assertion usage (e.g., using assertTrue instead of assertSame(true)), reducing false positives and test flakiness.
  • Provides accurate mock object typing via intersection types, preventing undefined method errors during test execution.
  • Supports roadmap for high-quality testing by integrating with existing PHPStan workflows, enabling early bug detection in CI pipelines.
  • Build vs Buy: Strong case for adopting this package over custom solutions due to active maintenance, community support, and seamless integration with PHPStan.
  • Key use cases: Teams using PHPStan for static analysis who need stricter PHPUnit test validation, especially in large codebases where test quality impacts release velocity.

When to Consider This Package

  • Adopt when your team uses PHPStan and PHPUnit together, especially if test assertions are error-prone (e.g., misuse of assertSame for booleans/null).
  • Ideal for projects where code quality and test correctness are critical (e.g., enterprise applications, high-traffic services).
  • Look elsewhere if:
    • Using a non-PHPStan toolchain (e.g., Psalm instead of PHPStan).
    • Testing framework is not PHPUnit (e.g., Pest, Codeception).
    • Project is small with minimal test coverage, where static analysis overhead outweighs benefits.

How to Pitch It (Stakeholders)

  • Executives: "This package reduces production bugs by catching test errors early in development. It integrates with existing PHPStan checks, requiring minimal setup but delivering significant ROI through fewer hotfixes and faster releases."
  • Engineering: "Seamlessly extends PHPStan to validate PHPUnit tests with auto-fixable rules for common mistakes (e.g., assertSame(true)assertTrue). Reduces manual code reviews for test quality, ensures consistent assertion usage, and improves mock object reliability with precise type inference."
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